diff --git a/crates/cli/src/command/push/mod.rs b/crates/cli/src/command/push/mod.rs index ea3ee5a..a8bec22 100644 --- a/crates/cli/src/command/push/mod.rs +++ b/crates/cli/src/command/push/mod.rs @@ -8,9 +8,19 @@ mod data_type_client_impl; mod flow_type_client_impl; mod function_client_impl; -pub async fn push(token: String, url: String, path: Option) { +pub async fn push( + token: String, + url: String, + version_option: Option, + path: Option, +) { let dir_path = path.unwrap_or_else(|| "./definitions".to_string()); + let version = match version_option { + None => String::from("0.0.0"), + Some(v) => v, + }; + let mut analyzer = Analyser::new(dir_path.as_str()); let mut data_type_client = SagittariusDataTypeServiceClient::new(url.clone(), token.clone()).await; @@ -25,7 +35,11 @@ pub async fn push(token: String, url: String, path: Option) { analyzer .data_types .iter() - .map(|d| d.definition_data_type.clone()) + .map(|d| { + let mut def = d.definition_data_type.clone(); + def.version = version.clone(); + return def; + }) .collect(), ) .await; @@ -34,7 +48,11 @@ pub async fn push(token: String, url: String, path: Option) { analyzer .flow_types .iter() - .map(|d| d.flow_type.clone()) + .map(|d| { + let mut def = d.flow_type.clone(); + def.version = version.clone(); + return def; + }) .collect(), ) .await; @@ -43,7 +61,11 @@ pub async fn push(token: String, url: String, path: Option) { analyzer .functions .iter() - .map(|d| d.function.clone()) + .map(|d| { + let mut def = d.function.clone(); + def.version = version.clone(); + return def; + }) .collect(), ) .await; diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index d24b137..aca796f 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -60,6 +60,9 @@ enum Commands { /// URL to Sagittarius. #[arg(short, long)] url: String, + /// Optional Version for all definitions + #[arg(short, long)] + version: Option, /// Optional path to root directory of all definitions. #[arg(short, long)] path: Option, @@ -87,6 +90,11 @@ async fn main() { path, ignore_warnings, } => command::watch::watch_for_changes(path, !ignore_warnings).await, - Commands::Push { token, url, path } => command::push::push(token, url, path).await, + Commands::Push { + token, + url, + version, + path, + } => command::push::push(token, url, version, path).await, } }