feat(version): group version commands under yt version (YT-10) #54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/version-command-YT-10"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes YT-10. Group all version-related surface under a single
yt versionnamespace.yt version(no subcommand) prints the same banner asyt --version.yt version checkdoes a HEAD against the Generic Package registry and reports whether a newer build is available, without downloading.yt version updatereplaces the running binary (the old top-levelyt update, identical flags--url,--dry-run,--force).yt updateis removed; clap returns its standard "unrecognized subcommand" error.--version/-Vcontinue to work unchanged.Implementation notes
src/commands/update.rswas split intosrc/commands/version/{mod.rs, check.rs, update.rs}. The freshness probe (HEAD+Last-Modifiedparse + comparison against the bakedYOUTRACK_CLI_BUILD_DATE) moved into a sharedfetch_remote_freshnesshelper inmod.rsthat returns aRemoteFreshness { remote_last_modified, baked_build_date, remote_is_newer }so bothcheckandupdatecan render or short-circuit off the same data.The existing update tests moved with the code;
check_writable_returns_friendly_message_on_readonly_dirswitched its root-detection from$USER == "root"to probing the actualcheck_writableresult, because the rust-builder docker image used byjust pre-commitdoes not propagate$USERand the test was failing onmainfor that reason.Doc strings referencing the old command surface were updated to
yt version update:build.rs,oci-build/Dockerfile,oci-build/Dockerfile.windows, the two Forgejobuild-*.ymlworkflows, and theCLAUDE.mdstatus line.Out-of-scope but bundled
Two pre-existing rustfmt drifts in
src/commands/article/{create,pull}.rsare included socargo fmt --check(and thereforejust pre-commit) is green. They are pure formatting; no logic change.Test plan
cargo test --all-targets(286 unit + 3 integration tests pass).just pre-commit(fmt, clippy, build, test inside rust-builder-musl docker) is green.yt --versionandyt -Vprint the version banner.yt versionprints the same banner.yt help versionlistsshow,check,update.yt version update --helpshows the same--url,--dry-run,--forceflags as the oldyt update.yt updatereturns clap's "unrecognized subcommand 'update'" error.Replace the top-level `yt update` subcommand with a `yt version` namespace that bundles three subcommands: `show` (default, prints the same banner as `yt --version`), `check` (HEAD-only registry freshness probe), and `update` (the existing self-replace flow, unchanged externally). Clap's `--version` / `-V` flags continue to work. The freshness logic moved into a shared `fetch_remote_freshness` helper in `commands/version/mod.rs` that returns the remote `Last-Modified`, the baked build date, and a precomputed `remote_is_newer` flag. Both `check` and `update` consume it: `update` short-circuits when the remote is not newer, `check` renders a one-liner without ever touching the binary. Module layout: `src/commands/update.rs` is split into `src/commands/version/{mod.rs, check.rs, update.rs}`. The existing update tests move with the code unchanged in behavior; the `check_writable_returns_friendly_message_on_readonly_dir` test now detects root by probing for an `Ok(())` from the readonly write instead of relying on the `USER` env var (which is unset inside the rust-builder docker image, causing the test to fail there on `main`). Doc references to `yt update` (build.rs, oci-build Dockerfiles, build-linux / build-windows workflow comments, CLAUDE.md status line) are rewritten to `yt version update`. Two unrelated rustfmt drifts in `src/commands/article/{create,pull}.rs` are picked up so `cargo fmt --check` is green. #YT-10 State Done