Skip to content

Commit 272f768

Browse files
committed
feat: added version to push command
1 parent 0660fa7 commit 272f768

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

crates/cli/src/command/push/mod.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ mod data_type_client_impl;
88
mod flow_type_client_impl;
99
mod function_client_impl;
1010

11-
pub async fn push(token: String, url: String, path: Option<String>) {
11+
pub async fn push(
12+
token: String,
13+
url: String,
14+
version_option: Option<String>,
15+
path: Option<String>,
16+
) {
1217
let dir_path = path.unwrap_or_else(|| "./definitions".to_string());
1318

19+
let version = match version_option {
20+
None => String::from("0.0.0"),
21+
Some(v) => v,
22+
};
23+
1424
let mut analyzer = Analyser::new(dir_path.as_str());
1525
let mut data_type_client =
1626
SagittariusDataTypeServiceClient::new(url.clone(), token.clone()).await;
@@ -25,7 +35,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
2535
analyzer
2636
.data_types
2737
.iter()
28-
.map(|d| d.definition_data_type.clone())
38+
.map(|d| {
39+
let mut def = d.definition_data_type.clone();
40+
def.version = version.clone();
41+
return def;
42+
})
2943
.collect(),
3044
)
3145
.await;
@@ -34,7 +48,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
3448
analyzer
3549
.flow_types
3650
.iter()
37-
.map(|d| d.flow_type.clone())
51+
.map(|d| {
52+
let mut def = d.flow_type.clone();
53+
def.version = version.clone();
54+
return def;
55+
})
3856
.collect(),
3957
)
4058
.await;
@@ -43,7 +61,11 @@ pub async fn push(token: String, url: String, path: Option<String>) {
4361
analyzer
4462
.functions
4563
.iter()
46-
.map(|d| d.function.clone())
64+
.map(|d| {
65+
let mut def = d.function.clone();
66+
def.version = version.clone();
67+
return def;
68+
})
4769
.collect(),
4870
)
4971
.await;

crates/cli/src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ enum Commands {
6060
/// URL to Sagittarius.
6161
#[arg(short, long)]
6262
url: String,
63+
/// Optional Version for all definitions
64+
#[arg(short, long)]
65+
version: Option<String>,
6366
/// Optional path to root directory of all definitions.
6467
#[arg(short, long)]
6568
path: Option<String>,
@@ -87,6 +90,11 @@ async fn main() {
8790
path,
8891
ignore_warnings,
8992
} => command::watch::watch_for_changes(path, !ignore_warnings).await,
90-
Commands::Push { token, url, path } => command::push::push(token, url, path).await,
93+
Commands::Push {
94+
token,
95+
url,
96+
version,
97+
path,
98+
} => command::push::push(token, url, version, path).await,
9199
}
92100
}

0 commit comments

Comments
 (0)