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
30 changes: 26 additions & 4 deletions crates/cli/src/command/push/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>) {
pub async fn push(
token: String,
url: String,
version_option: Option<String>,
path: Option<String>,
) {
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;
Expand All @@ -25,7 +35,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
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;
Expand All @@ -34,7 +48,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
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;
Expand All @@ -43,7 +61,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
analyzer
.functions
.iter()
.map(|d| d.function.clone())
.map(|d| {
let mut def = d.function.clone();
def.version = version.clone();
return def;
})
.collect(),
)
.await;
Expand Down
10 changes: 9 additions & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ enum Commands {
/// URL to Sagittarius.
#[arg(short, long)]
url: String,
/// Optional Version for all definitions
#[arg(short, long)]
version: Option<String>,
/// Optional path to root directory of all definitions.
#[arg(short, long)]
path: Option<String>,
Expand Down Expand Up @@ -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,
}
}