Skip to main content

romm_cli/commands/
update.rs

1use anyhow::Result;
2use self_update::cargo_crate_version;
3
4/// Substring inside each GitHub release archive name (`romm-cli-….tar.gz` / `.zip`).
5/// `self_update` matches on this; our assets use `macos-x86_64` etc., not the full Rust triple.
6fn github_release_asset_key() -> &'static str {
7    match (std::env::consts::OS, std::env::consts::ARCH) {
8        ("macos", "x86_64") => "macos-x86_64",
9        ("macos", "aarch64") => "macos-aarch64",
10        ("linux", "x86_64") => "linux-x86_64",
11        ("linux", "aarch64") => "linux-aarch64",
12        ("windows", "x86_64") => "windows-x86_64",
13        _ => self_update::get_target(),
14    }
15}
16
17/// Handle the `update` command.
18pub fn handle() -> Result<()> {
19    let status = self_update::backends::github::Update::configure()
20        .repo_owner("patricksmill")
21        .repo_name("romm-cli")
22        .bin_name("romm-cli")
23        .target(github_release_asset_key())
24        .show_download_progress(true)
25        .current_version(cargo_crate_version!())
26        .build()?
27        .update()?;
28
29    println!("Update status: `{}`!", status.version());
30    Ok(())
31}