Skip to content

refactor: parse the command line with zig-common argparse - #73

Merged
HaoZeke merged 2 commits into
mainfrom
refactor/keep-logs-argparse
Nov 26, 2026
Merged

HaoZeke merged 2 commits into
mainfrom
refactor/keep-logs-argparse

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

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.

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.
@HaoZeke
HaoZeke merged commit 56fadab into main Nov 26, 2026
8 checks passed
@HaoZeke
HaoZeke deleted the refactor/keep-logs-argparse branch November 26, 2026 07:08
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.

1 participant