stmo_cli/commands/
update.rs1#![allow(clippy::missing_errors_doc)]
2
3use anyhow::Result;
4
5pub fn update() -> Result<()> {
6 let status = std::process::Command::new("cargo")
7 .args(["binstall", "--no-confirm", "stmo-cli"])
8 .status();
9
10 match status {
11 Ok(s) if s.success() => {
12 println!("stmo-cli updated successfully.");
13 return Ok(());
14 }
15 _ => eprintln!("cargo binstall not available, falling back to cargo install"),
16 }
17
18 let status = std::process::Command::new("cargo")
19 .args(["install", "stmo-cli"])
20 .status()?;
21
22 if status.success() {
23 println!("stmo-cli updated successfully.");
24 Ok(())
25 } else {
26 anyhow::bail!("cargo install stmo-cli failed");
27 }
28}