refactor(cli): parse arguments with clap - #211
Merged
Merged
Conversation
5 tasks
tupe12334
force-pushed
the
refactor/extract-unit-tests
branch
2 times, most recently
from
September 24, 2026 08:19
a6b979c to
18c40e4
Compare
Replace the hand-written slice matching in main.rs with a clap derive parser (`Cli` + `CliCommand`). Behaviour is kept: - no subcommand still reads a hook event from stdin - `init [--global]`, `validate`, `clean [--global]`, `-V/--version` - usage errors still exit 1 (clap's default is 2, which steplock uses for hook failures) Adds `steplock help` and per-command `--help` for free. clap is resolved to 4.5.x in Cargo.lock because 4.6 needs Rust 1.85 (MSRV is 1.75). Also promotes clippy::needless_pass_by_value to deny. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tupe12334
force-pushed
the
refactor/clap-cli
branch
from
September 24, 2026 08:23
f07363c to
a72357b
Compare
tupe12334
marked this pull request as ready for review
September 24, 2026 08:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #209 (review request: "use lib for the cli"). Originally stacked on #210; now rebased onto
mainafter #209 and #210 merged.match args.as_slice()incore/src/bin/main.rswith aclapderive parser (Cliplus theCliCommandsubcommands). The oldprint_helpis gone. Its checklist-files and global-checklists sections now live inafter_help.init [--global],validate,clean [--global], and-V/--version(printssteplock X.Y.Z) work as before.clap's default is 2, which steplock uses for hook failures, somainmaps it withtry_parseanduse_stderr().steplock help,steplock <command> --help, and usage errors that name the bad argument.clap4.6 needs Rust 1.85, so Cargo.lock pinsclap4.5.61. I resolved it withCARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback. Every new transitive dependency needs Rust ≤ 1.74.clippy::needless_pass_by_valueis nowdeny.Note on MSRV (pre-existing, not changed here): real Rust 1.75 can't build steplock even on
main. The existingtoml 1.1dependency pulls inserde_spanned 1.1.1, whose manifest Cargo 1.75 fails to parse, andCargo.lockis lockfile v4, which Cargo 1.75 can't read. TheMSRV (1.75)CI job probably still passes becauserust-toolchain.tomlpinsstable, which overrides the toolchain the job installs. Pinningclapto 4.5 keeps this PR from making that worse, but a separate fix is needed, either raisingrust-versionor pinning the older dependencies.Test plan
cargo testpasses (6 new parser unit tests, includingCli::command().debug_assert(), and 1 new CLI--helptest)cargo clippy --all-targets -- -D warningspassescargo fmt -- --checkpassessteplock --helplists commands and the extra sections;steplock --bogusprints a usage error and exits 1;steplock -Vprintssteplock 0.1.0🤖 Generated with Claude Code