Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/pkg-')
defaults:
run:
working-directory: "./reader/rust"
working-directory: "./crates/package"
steps:
- name: Checkout Code
uses: actions/checkout@v5
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

- name: Build project
run: cargo run bundle --path ../definitions --out ../bundles
working-directory: "./cli"
working-directory: "./crates/cli"

- name: Archive definitions folder
run: |
Expand All @@ -94,7 +94,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/cli-')
defaults:
run:
working-directory: "./cli"
working-directory: "./crates/cli"
steps:
- name: Checkout Code
uses: actions/checkout@v5
Expand Down
90 changes: 72 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[workspace]
members = ["cli", "reader/rust"]
members = ["crates/cli", "crates/package"]
resolver = "3"

[workspace.package]
version = "0.0.1"
edition = "2024"

[workspace.dependencies]
serde = "1.0.219"
serde_json = "1.0.140"
tucana = "0.0.37"
tucana = "0.0.38"
clap = "4.5.41"
colored = "3.0"
tabled = "0.20"
Expand All @@ -19,5 +18,4 @@ tokio = "1.47.0"
futures = "0.3.31"
zip = "6.0.0"
bytes = "1.10.1"
prost = "0.14.1"
code0-definition-reader= "0.0.13"
prost = "0.14.1"
5 changes: 2 additions & 3 deletions cli/Cargo.toml → crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ description = "The cli for managing the Code0-Definitions"
repository = "https://github.com/code0-tech/code0-definitions"
homepage = "https://code0.tech"
license = "Apache-2.0"
readme = "../README.md"
readme = "../../README.md"

[dependencies]
clap = { workspace = true, features = ["derive"] }
code0-definition-reader = { workspace = true }
tucana = { workspace = true }
colored = { workspace = true }
tabled = { workspace = true }
Expand All @@ -22,4 +21,4 @@ tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros"] }
futures = { workspace = true }
zip = { workspace = true }
bytes = { workspace = true }
prost = {workspace = true}
prost = { workspace = true }
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::formatter::{error, warning};
use code0_definition_reader::reader::Meta;
use crate::parser::Meta;
use std::cmp::PartialEq;
use std::path::Path;
use std::process::exit;
Expand Down Expand Up @@ -66,13 +66,6 @@ impl Reporter {
.filter(|p| p.kind.severity() == Severity::Warning)
.collect()
}

pub fn get_debug(&self) -> Vec<&Diagnose> {
self.diagnose
.iter()
.filter(|p| p.kind.severity() == Severity::Debug)
.collect()
}
}

pub enum Severity {
Expand Down
4 changes: 2 additions & 2 deletions cli/src/analyser/mod.rs → crates/cli/src/analyser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::analyser::diagnostics::DiagnosticKind::{
UndefinedGenericKey, UndefinedTranslation, UnusedGenericKey,
};
use crate::analyser::diagnostics::{Diagnose, DiagnosticKind, Reporter};
use code0_definition_reader::parser::Parser;
use code0_definition_reader::reader::{Meta, MetaType, Reader};
use crate::parser::Parser;
use crate::parser::{Meta, MetaType, Reader};
use tucana::shared::data_type_identifier::Type;
use tucana::shared::definition_data_type_rule::Config;
use tucana::shared::{DataTypeIdentifier, DefinitionDataType, FlowType, RuntimeFunctionDefinition};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use code0_definition_reader::parser::Parser;
use crate::parser::Parser;
use prost::Message;
use std::fs;
use std::io::Write;
Expand All @@ -23,7 +23,7 @@ pub fn bundle(path: Option<String>, out: Option<String>) {
for feature in parser.features {
feature.data_types.iter().for_each(|data_type| {
let mut buf = Vec::new();
if let Ok(_) = data_type.encode(&mut buf) {
if data_type.encode(&mut buf).is_ok() {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
Expand All @@ -40,7 +40,7 @@ pub fn bundle(path: Option<String>, out: Option<String>) {

feature.flow_types.iter().for_each(|flow_type| {
let mut buf = Vec::new();
if let Ok(_) = flow_type.encode(&mut buf) {
if flow_type.encode(&mut buf).is_ok() {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
Expand All @@ -57,7 +57,7 @@ pub fn bundle(path: Option<String>, out: Option<String>) {

feature.runtime_functions.iter().for_each(|function| {
let mut buf = Vec::new();
if let Ok(_) = function.encode(&mut buf) {
if function.encode(&mut buf).is_ok() {
let path = format!(
"{}/{}_{}_{}.pb",
&out_path,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::formatter::{info, success};
use code0_definition_reader::parser::Parser;
use crate::parser::Parser;
use colored::Colorize;
use prost::Message;
use tucana::shared::DefinitionDataType;

pub fn search_definition(name: String, path: Option<String>) {
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::analyser::Analyser;
use crate::formatter::{success, success_table};
use crate::parser::{Feature, Parser};
use crate::table::{feature_table, summary_table};
use code0_definition_reader::parser::{Feature, Parser};

pub fn search_feature(name: Option<String>, path: Option<String>) {
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::analyser::Analyser;
use crate::formatter::{success, success_table};
use crate::parser::Parser;
use crate::table::summary_table;
use code0_definition_reader::parser::Parser;

pub fn report_errors(path: Option<String>) {
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
Expand Down
File renamed without changes.
32 changes: 0 additions & 32 deletions cli/src/formatter.rs → crates/cli/src/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ pub fn default(string: String) {
println!("{}", string);
}

pub fn default_table<I, T>(iter: I)
where
I: IntoIterator<Item = T>,
T: Tabled,
{
println!("{}", print_table(iter));
}

pub fn success(string: String) {
println!("\n{}: {}", "success".green(), string);
}
Expand All @@ -22,10 +14,6 @@ pub fn info(string: String) {
println!("\n{}: {}", "info".blue(), string);
}

pub fn success_highlight(highlight: String, string: String) {
println!("{} {}", highlight.green(), string);
}

pub fn success_table<I, T>(iter: I)
where
I: IntoIterator<Item = T>,
Expand All @@ -46,30 +34,10 @@ pub fn error_highlight(highlight: String, string: String) {
println!("{} {}", highlight.red(), string);
}

pub fn error_table<I, T>(iter: I)
where
I: IntoIterator<Item = T>,
T: Tabled,
{
println!("{}", print_table(iter).red());
}

pub fn warning(string: String, path: &String) -> String {
format!("\n{}: {} {}", "warning".yellow(), string, print_path(path))
}

pub fn warning_highlight(highlight: String, string: String) {
println!("{} {}", highlight.yellow(), string);
}

pub fn warning_table<I, T>(iter: I)
where
I: IntoIterator<Item = T>,
T: Tabled,
{
println!("{}", print_table(iter).yellow());
}

fn print_table<I, T>(iter: I) -> String
where
I: IntoIterator<Item = T>,
Expand Down
2 changes: 2 additions & 0 deletions cli/src/main.rs → crates/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use clap::{Parser as ClapParser, Subcommand};

pub mod parser;

mod analyser;
mod command;
mod formatter;
Expand Down
Loading