Skip to content

feat(cli): add self update command#381

Open
pesap wants to merge 1 commit into
mainfrom
feat/379-add-torc-self-update-command
Open

feat(cli): add self update command#381
pesap wants to merge 1 commit into
mainfrom
feat/379-add-torc-self-update-command

Conversation

@pesap

@pesap pesap commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Closes #379

Summary

Adds a draft implementation of torc self update [TARGET_VERSION] under the new self
namespace. The command is local-only, uses axoupdater receipts to guard eligible standalone
installer updates, supports --token/GITHUB_TOKEN, and gives install-source guidance when the
current executable cannot be self-updated.

Draft PR: not ready to merge until maintainer review and forge CI are complete.

Acceptance criteria

  • Addressed — Adds torc self update [TARGET_VERSION] under a new self namespace.
    Evidence: src/cli.rs wires SelfCommand as name = "self"; cargo +1.95.0 run --quiet --bin torc -- self update --help prints Usage: torc self update [OPTIONS] [TARGET_VERSION].
  • Addressed — Command is local-only: it does not require a Torc server, does not run server
    version checks, and ignores --standalone startup. Evidence: src/main.rs excludes
    Commands::SelfCommand { .. } from requires_server; no server config is passed to the command
    handler.
  • Addressed — Uses AxoUpdater::new_for("torc"), loads the standalone installer receipt, and
    checks that the receipt belongs to std::env::current_exe() before updating. Evidence:
    src/client/commands/self_update.rs calls AxoUpdater::new_for(APP_NAME), load_receipt(), and
    check_receipt_is_for_this_executable() before run_sync().
  • Addressed — Supports an optional target release tag/version and a GitHub token via --token
    and GITHUB_TOKEN. Evidence: SelfUpdateArgs has optional TARGET_VERSION and
    #[arg(long, env = "GITHUB_TOKEN")]; tests cover tag vs plain semver target routing.
  • Addressed — Missing or mismatched receipt exits non-zero and explains that self-update is only
    available for standalone installer installs. Evidence: missing-receipt unit test and manual CLI
    command return exit 1 with the standalone installer requirement.
  • Addressed — Unsupported installs get useful guidance for cargo/crates.io, package-manager,
    Docker, site-managed, and manual archive installs. Evidence: unsupported_install_guidance() and
    missing-receipt test assert the guidance categories.
  • Addressed — GitHub API rate-limit failures recommend using a token instead of surfacing an
    opaque error. Evidence: is_github_rate_limit() maps unauthenticated 403/429 reqwest errors to a
    token-focused message.
  • Addressed — Tests cover at least missing-receipt behavior and CLI help output. Evidence:
    cargo +1.95.0 test self_update runs 5 passing tests including missing receipt and help output.

Deviations from the original plan

  • No release workflow or installer publishing changes are included. Current repository releases ship
    archives, not cargo-dist installer assets/receipts, so actual successful self-update requires a
    standalone installer distribution path to exist. This should stay as a follow-up if desired.
  • Used cargo +1.95.0 locally because the active default toolchain was Rust 1.92 while the crate now
    requires Rust 1.95.

Testing Strategy

cargo +1.95.0 test self_update
cargo +1.95.0 run --quiet --bin torc -- self update --help
tmpdir=$(mktemp -d); AXOUPDATER_CONFIG_PATH="$tmpdir" cargo +1.95.0 run --quiet --bin torc -- self update; status=$?; rm -rf "$tmpdir"; test "$status" -ne 0
cargo +1.95.0 fmt --all -- --check
DATABASE_URL=sqlite:db/sqlite/dev.db sqlx database setup --source torc-server/migrations
cargo +1.95.0 clippy --all --all-targets --all-features -- -D warnings
PATH="$HOME/.dprint/bin:$PATH" dprint check

References

@pesap pesap requested a review from daniel-thom June 8, 2026 18:59
@pesap pesap force-pushed the feat/379-add-torc-self-update-command branch from 5f4f871 to 9f65e80 Compare June 8, 2026 21:42
@pesap pesap marked this pull request as ready for review June 8, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add torc self update command

1 participant