kimun_notes/cli/commands/
update.rs1use color_eyre::eyre::Result;
5
6use crate::update;
7
8pub async fn run(check_only: bool) -> Result<()> {
10 let config_dir = crate::settings::config_dir()?;
11
12 let latest = update::latest_release().await?;
15 let status = update::status_for(&config_dir, &latest);
16
17 println!("Current version: {}", status.current);
18 println!("Latest version: {}", status.latest);
19
20 if !status.update_available {
21 println!("kimün is up to date.");
22 return Ok(());
23 }
24
25 println!("Update available: {} → {}", status.current, status.latest);
26
27 if check_only {
28 return Ok(());
29 }
30
31 if !status.channel.self_update_eligible() {
32 match status.channel.upgrade_hint() {
33 Some(cmd) => println!("To upgrade, run: {cmd}"),
34 None => println!(
35 "This install cannot self-update. Download the latest release from {}",
36 update::releases_url()
37 ),
38 }
39 return Ok(());
40 }
41
42 println!("Downloading and installing {}...", status.latest);
43 update::install(latest).await?;
44 println!(
45 "Updated to {}. Restart kimün to use the new version.",
46 status.latest
47 );
48 Ok(())
49}