Skip to main content

Module updater

Module updater 

Source
Expand description

Self-update support for yui, using the shared kaishin library.

Thin sync facade around kaishin’s async API so the rest of yui can stay synchronous. Same shape as renri’s src/updater.rs; the only yui-specific bit is the hardcoded (owner, repo, bin) triple — yui’s crate name is yui-cli (because crates.io’s yui is taken by an unrelated abandoned crate), but the repo and binary are both yui, so going through env!("CARGO_PKG_NAME") the way renri does would produce the wrong GitHub Release URL.

The module exposes two layers:

  • run_self_update — drives the yui self-update subcommand (interactive / --yes / --check).
  • Checker + maybe_spawn_auto_update_check / finalize_auto_update_check — the daily background banner shown after every other subcommand, the way rvpm / renri do it. [ui] auto_update_check = false in config.toml opts out, and [ui] update_check_interval = "..." overrides the default 24h cadence.

Structs§

Checker
Blocking facade over kaishin::Checker — yui’s main loop is synchronous, so the async check_and_save call goes through a fresh current_thread runtime each time. Same shape as renri.

Enums§

AutoUpdateHandle
Handle for an ongoing or cached background update check. Mirrors renri’s AutoUpdateHandle.

Functions§

default_interval
Default interval between background update checks (24 hours).
finalize_auto_update_check
Print the update banner (if any) before the binary exits. Waits up to one second for an in-flight background check to finish; on timeout, falls back to the previously-cached release so the user still gets the nudge. Skips the leading newline when the banner would be empty (e.g. kaishin returning a release that doesn’t actually outrank the running version). (PR #76 review by gemini-code-assist.)
maybe_spawn_auto_update_check
Spawn a background check on std::thread::spawn if the user hasn’t opted out and the cache is older than the configured interval. The returned handle is consumed by finalize_auto_update_check at shutdown.
run_self_update
Run yui self-update. Flags map directly onto kaishin’s UpdateOptions: