Skip to content

Commit

Permalink
bin: show update script for linux/macos
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkIsGrim committed Dec 19, 2024
1 parent 9f04af8 commit 733645a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions bin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,27 @@ pub fn execute(cli: &Cli) -> Result<(), Error> {
info!("HEMTT {version} is available, please update");
if let Ok(path) = std::env::current_exe() {
trace!("HEMTT is installed at: {}", path.display());
if path.display().to_string().contains("\\Winget\\") {
info!(
"HEMTT is installed via winget, run `winget upgrade hemtt` to update"
);
let os = std::env::consts::OS;

let (message, filter) = match os {
"windows" => (
"HEMTT is installed via winget, run `winget upgrade hemtt` to update",
"\\Winget\\".to_string()
),
_ => (
"HEMTT is installed in home directory, run `curl -sSf https://hemtt.dev/install.sh | sh` to update", {
let mut default = dirs::home_dir().expect("home directory exists");
if os != "macos" {
default = default.join(".local")
};

default.join("bin").display().to_string()
}
),
};

if path.display().to_string().contains(&filter) {
info!(message)
}
}
}
Expand Down

0 comments on commit 733645a

Please sign in to comment.