Skip to content

Commit ba69518

Browse files
Fixed "update" command
1 parent fba444b commit ba69518

3 files changed

Lines changed: 49 additions & 9 deletions

File tree

cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cortexflow-cli"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2024"
55
description = "CortexFlow command line interface made to interact with the CortexBrain core components"
66
authors = ["Lorenzo Tettamanti", "Pranav Verma", "Lorenzo Bradanini"]

cli/src/essential.rs

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ use serde::Serialize;
55
use std::fs::OpenOptions;
66

77
use colored::Colorize;
8-
use std::time::Duration;
98
use std::thread;
9+
use std::time::Duration;
10+
11+
use std::process::Command;
1012

1113
pub struct GeneralData {
1214
env: String,
@@ -72,14 +74,52 @@ impl GeneralData {
7274
}
7375

7476
pub fn update_cli() {
75-
println!("Updating CortexFlow CLI");
76-
println!("Looking for a newer version");
77+
println!("{} {}", "=====>".blue().bold(), "Updating CortexFlow CLI");
78+
println!(
79+
"{} {}",
80+
"=====>".blue().bold(),
81+
"Looking for a newer version"
82+
);
83+
84+
let output = Command::new("cargo")
85+
.args(["update", "cortexflow-cli"])
86+
.output()
87+
.expect("error");
88+
89+
if !output.status.success() {
90+
eprintln!(
91+
"Error updating CLI : {}",
92+
String::from_utf8_lossy(&output.stderr)
93+
);
94+
} else {
95+
println!("✅ Updated CLI");
96+
}
7797
}
7898
pub fn info(general_data: GeneralData) {
79-
println!("{} {} {}","=====>".blue().bold(),"Version:", GeneralData::VERSION);
80-
println!("{} {} {}","=====>".blue().bold(),"Author:", GeneralData::AUTHOR);
81-
println!("{} {} {}","=====>".blue().bold(),"Description:", GeneralData::DESCRIPTION);
82-
println!("{} {} {}","=====>".blue().bold(),"Environment:", general_data.get_env());
99+
println!(
100+
"{} {} {}",
101+
"=====>".blue().bold(),
102+
"Version:",
103+
GeneralData::VERSION
104+
);
105+
println!(
106+
"{} {} {}",
107+
"=====>".blue().bold(),
108+
"Author:",
109+
GeneralData::AUTHOR
110+
);
111+
println!(
112+
"{} {} {}",
113+
"=====>".blue().bold(),
114+
"Description:",
115+
GeneralData::DESCRIPTION
116+
);
117+
println!(
118+
"{} {} {}",
119+
"=====>".blue().bold(),
120+
"Environment:",
121+
general_data.get_env()
122+
);
83123
}
84124

85125
fn is_supported_env(env: &str) -> bool {

0 commit comments

Comments
 (0)