Repository navigation
check_no_game_data: -h/--help print the usage and an unknown option exits 2 (EGEN-NOGAMEDATA-ARGS) - #6396
Open
evilclanker9000 wants to merge 3 commits into
Open
check_no_game_data: -h/--help print the usage and an unknown option exits 2 (EGEN-NOGAMEDATA-ARGS)#6396evilclanker9000 wants to merge 3 commits into
evilclanker9000 wants to merge 3 commits into
Conversation
…ipped as paths The guard takes every argument as a path, so -h and --help were checked like one, skipped as not a file, and it exited 0 with no output. They now print the module docstring, whose head is the usage, and check nothing.
…y skipped path An unknown option was taken for a file name, skipped as not a file, and the guard exited 0 - the worst answer for a guard that is meant to fail on a hit. It now names the option and the usage on stderr and exits 2, the exit code the other tools use for bad arguments.
…th a dash Rejecting options would otherwise take a path called -foo for a misspelt option. Every argument that starts with '-' is now the option that is named, -h/--help may come after paths, and the usage lists the separator.
|
Tested head
Clean CLI argument handling without breaking existing path checks or repository verification. Synthetic tests only, no game files. AI-assisted. |
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.
scripts/check_no_game_data.pytook every argument as a file path, so-h/--helpwere checked like one, skipped as not a file, and the guard exited 0 with no output at all. A misspelt option was skipped the same way: a typo in the command could make the no-game-data gate exit 0 while checking nothing, which is the one failure this guard exists to catch.What changed:
-hand--helpprint the module docstring, whose head is the usage, and check nothing (exit 0).-is one line,unknown option <flag>, plus the usage on stderr, and exit 2 — the code the other tools here use for bad arguments.--ends the options, so a path whose own name starts with-can still be checked:python3 -I scripts/check_no_game_data.py -- -weird.bin.Three commits, one per behaviour: the help, the unknown option, the
--separator (with the wider option scan it needs), each with its own test.Test
python -I tests/test_check_no_game_data.pyBefore, on
main(8497c70) with the three new tests added and nothing else:After:
Ran 11 tests in 7.2s ... OK(the--test included).The script still passes on the repository itself:
python -I scripts/check_no_game_data.py→ exit 0.No GPU needed.
Notes
-hprints it instead of a new section.--commitsis deliberately not the unknown-option sample in the test: check_no_game_data: --commits also checks files a pull request adds and deletes again #6079 adds--commitsto this same script, so a test that asserts it is unknown would break when that PR lands. The samples are--frobnicateand-x.--separator and the scan over every option position came out of the same fix: rejecting options would otherwise take a path called-foofor a misspelt option, which worked before.AI-assisted.