Repository navigation
refactor: parse the command line with zig-common argparse - #73
Merged
Merged
Conversation
The pin on main is zig-common v0.12.0, which has no argparse module. v0.13.0 is the first release tag that exports zig_common.argparse, at commit 2eea6b7fe8f328e56c63647b9523c4a7fe80b56a, so build.zig.zon now points at that tag and the hash zig fetch recorded for it. That release widens lockExclusive and lockExclusiveCancel to an optional u64 timeout. The metrics writer already passes null, which is a valid optional timeout, so the pin needs no other source change. The debug build passes.
A handwritten loop used to scan the tokens of each subcommand: failed, rotate, why, history, failures, loads, runs, used, usage, pending, test-bundle, test-compare and lifecycle. One CommandSpec table in src/cli_parse.zig now replaces those loops. It is built on zig_common.argparse from v0.13.0. The table keeps the old scan order. An unknown option, a missing value, an empty or dash value, a mutex clash, and a bad usage epoch or test-bundle module still die on the first fault, with the same line and exit status 2. why, history, and failures still print help when help appears anywhere in the arguments. The top-level dispatch still matches a command name and does no option scan. A bare invocation still prints usage on stdout and exits 2, and version still ignores anything after it. Checks that run after the scan stay where they were: dates, day counts, the lock timeout, newline rejection, the run and latest clash, the easyconfigs and rebuild-set clash, and the requirement that test-compare see two files. The command files are shorter by more than src/cli_parse.zig adds.
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.
build: pin zig-common at v0.13.0
The pin on main is zig-common v0.12.0, which has no argparse module.
v0.13.0 is the first release tag that exports zig_common.argparse, at
commit 2eea6b7fe8f328e56c63647b9523c4a7fe80b56a, so build.zig.zon now
points at that tag and the hash zig fetch recorded for it.
That release widens lockExclusive and lockExclusiveCancel to an
optional u64 timeout. The metrics writer already passes null, which
is a valid optional timeout, so the pin needs no other source change.
The debug build passes.
refactor: parse the command line with zig-common argparse
A handwritten loop used to scan the tokens of each subcommand: failed,
rotate, why, history, failures, loads, runs, used, usage, pending,
test-bundle, test-compare and lifecycle. One CommandSpec table in
src/cli_parse.zig now replaces those loops. It is built on
zig_common.argparse from v0.13.0.
The table keeps the old scan order. An unknown option, a missing
value, an empty or dash value, a mutex clash, and a bad usage epoch or
test-bundle module still die on the first fault, with the same line
and exit status 2. why, history, and failures still print help when
help appears anywhere in the arguments.
The top-level dispatch still matches a command name and does no option
scan. A bare invocation still prints usage on stdout and exits 2, and
version still ignores anything after it. Checks that run after the
scan stay where they were: dates, day counts, the lock timeout, newline
rejection, the run and latest clash, the easyconfigs and rebuild-set
clash, and the requirement that test-compare see two files.
The command files are shorter by more than src/cli_parse.zig adds.