kaishin
Universal self-update library for Rust CLIs, extracted from rvpm and renri.
Features
- GitHub Releases API integration
- Automatic installation method detection (cargo install / dev build / direct binary)
- Background update check with throttling via [
Checker] - Silent background auto-update (Claude-Code style) via [
Checker::auto_update] / [Checker::spawn_auto_update] - Customizable update banner
- Interactive/Non-interactive update flow
Usage
Add this to your Cargo.toml:
[]
= "0.1"
Self-Update Command
use ;
async
Background Update Check
Using Checker to handle state and throttling automatically:
use ;
async
Silent Background Auto-Update
Like Claude Code, you can update silently in the background instead of just
notifying. spawn_auto_update fires a detached task that checks, downloads,
and replaces the binary with no prompts and no output. The running process
keeps the old binary; the new version takes effect on the next launch.
use ;
async
Notes:
- A dev build (under
target/) is never overwritten — the call is a no-op. - For a
cargo install-managed binary, auto-update only swaps the GitHub release asset; it never triggers a (slow, noisy)cargo installrebuild on this path. If no matching asset exists, the update is skipped. - Updates are serialised across processes by an OS advisory lock, so two instances starting at once won't both self-replace (and the lock is released automatically if a process exits or crashes).
- Use [
Checker::auto_update] directly (instead ofspawn_auto_update) if you want to await the result and learn which version was installed.
License
MIT