Repository navigation
check_apt_key: -h/--help print the usage and description instead of a usage error (EGEN-APTKEY-CLI) - #7657
check_apt_key: -h/--help print the usage and description instead of a usage error (EGEN-APTKEY-CLI)#7657Vonsek wants to merge 3 commits into
Conversation
main() parsed argv by hand, so -h and --help fell through to the 'wrong argument count' branch: the bare usage line on stderr and exit 2, the same code as a usage error. argparse prints the usage, the arguments and the module docstring's first line as the description, and exits 0; a missing argument, an unknown option and a bad fingerprint still exit 2.
The exit-code sentence is what a CI author reads before wiring this into a workflow; it now says that -h/--help exits 0, so 0 no longer means only 'the key matched'.
The new cases run the script: -h and --help must print the usage, both arguments and the docstring's description on stdout and exit 0 (on main they exit 2 with the bare usage line on stderr), an unknown option must exit 2, and the no-argument usage error must keep naming the usage. Red on main, green with the argparse change.
devnull34
left a comment
There was a problem hiding this comment.
Verified via Claude Code (Opus 5.5): Swapping the hand-rolled argument check for argparse makes -h/--help print the usage, both arguments and description on stdout and exit 0. Unknown options and missing arguments still exit 2 with usage error. All 15 tests in tests/test_check_apt_key.py pass cleanly.
|
Tested b68bd2a on Arch Linux, Python 3.14.10, CPU only: pass — first Linux check. tests/test_check_apt_key.py 15/15 OK. Negative control: base script → exactly the targeted test fails (exit 2 instead of 0 on -h); restored, green again. No game files. AI-assisted. |
|
Tested Checks
AI-assisted. |
sds-228
left a comment
There was a problem hiding this comment.
Re-reviewed at the current head. The hand-rolled argument check is now argparse: -h/--help print the usage, both arguments and the description on stdout with exit 0, while missing arguments, unknown options and bad fingerprints keep exit 2.
CPU-only verification: the focused help test passes here and fails on the parent. Two workflow assertions are red in my checkout on the parent as well. Compile and no-game-data checks are clean.
AI-assisted (OpenCode).
|
Tested b68bd2a on Windows 11 (CPU only, no GPU needed): pass Windows 11 Pro, Python 3.14.7, no GPU or game files involved; pytest/numpy/Pillow pinned from
AI-assisted (Claude Code, Claude Opus 5.5). |
|
Tested b68bd2a on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass. Ran the test files this PR adds or changes, from a clean checkout of the PR head: AI-assisted (Claude Code). |
Item: EGEN-APTKEY-CLI (found and claimed in #7496)
scripts/check_apt_key.pyparsedargvby hand:len(argv) != 2printedusage: check_apt_key.py KEYFILE FINGERPRINTon stderr and returned 2.
-hand--helptherefore landed in that branch, so the tool answered a help request with theexit code it uses for a usage error and never showed its description or its two arguments. Every other script in
scripts/answers--helpand exits 0, and AGENTS.md asks contributors and agents to quote a tool's--helpusage line;this is the one script where that does not work. Two CI workflows call it (
.github/workflows/ci.yml:138,.github/workflows/runtime.yml:329), with two arguments.What changed
main()builds anargparse.ArgumentParser(prog="check_apt_key.py", description = the module docstring's firstline) and takes the two positionals as
KEYFILE/FINGERPRINT, so the printed usage stays the line the docstringdocuments.
-h/--helpprint the usage, both arguments and the description on stdout and exit 0.now also says that
-h/--helpexits 0.Test
Before (main, with the same test file and
scripts/check_apt_key.pyreverted to main's):After:
The new cases run the script:
-hand--helpmust exit 0 with the usage,KEYFILE,FINGERPRINTand the docstring'sfirst line on stdout and nothing on stderr;
--commitsmust exit 2 with the usage; the no-argument case must keepexiting 2 and naming the usage.
python -m compileall -q scripts testspasses, andpython -I scripts/check_no_game_data.py scripts/check_apt_key.py tests/test_check_apt_key.pyreports nothing, so nothinghere reads or adds game data.
No GPU needed. Windows 11, Python 3.12.
Notes
progexplicit so the printed usage line matches what the docstring and the CI logs show.not a 40-digit key fingerprint,no such key file) as they were: only argumentparsing moved, which is the same fix
check_no_game_data.pygets in check_no_game_data: -h/--help print the usage and an unknown option exits 2 (EGEN-NOGAMEDATA-ARGS) #6396.claim.ps1) refusedEGEN-APTKEY-HELPbecause my ownclaiming:line was already in Coordinating who works on what (44) (moved to #7599) #7496, sothe item was re-posted and claimed as
EGEN-APTKEY-CLI(comment atCoordinating who works on what (44) (moved to #7599) #7496 (comment)).
AI-assisted.