use anyhow::{Context, Result};
const REPO_OWNER: &str = "out-layer";
const REPO_NAME: &str = "outlayer-cli";
const BIN_NAME: &str = "outlayer";
pub fn run() -> Result<()> {
let current = env!("CARGO_PKG_VERSION");
println!("outlayer v{current} — checking {REPO_OWNER}/{REPO_NAME} for updates…");
let status = self_update::backends::github::Update::configure()
.repo_owner(REPO_OWNER)
.repo_name(REPO_NAME)
.bin_name(BIN_NAME)
.current_version(current)
.show_download_progress(true)
.build()
.context("failed to configure self-update")?
.update()
.context(
"self-update failed — check your network, or that a release asset exists \
for this platform. You can always reinstall with: \
cargo install --git https://github.com/out-layer/outlayer-cli --force",
)?;
if status.updated() {
println!("✓ Updated outlayer to v{}", status.version());
} else {
println!("✓ Already up to date (v{current})");
}
Ok(())
}