Skip to content

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
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-nogamedata-args
Open

evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:deepseek/10-nogamedata-args

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

scripts/check_no_game_data.py took every argument as a file path, so -h/--help were 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:

  • -h and --help print the module docstring, whose head is the usage, and check nothing (exit 0).
  • Any other argument that starts with - is one line, unknown option <flag>, plus the usage on stderr, and exit 2 — the code the other tools here use for bad arguments.
  • A lone -- 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.py

Before, on main (8497c70) with the three new tests added and nothing else:

FAIL: test_help_prints_the_docstring_and_checks_nothing (flag='-h'/'--help')
AssertionError: 'python3 -I scripts/check_no_game_data.py' not found in ''
FAIL: test_unknown_option_is_a_usage_error_instead_of_a_skipped_path (flag='--frobnicate')
AssertionError: 0 != 2
Ran 10 tests ... FAILED (failures=4)

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

  • Only one tool and its test change. No doc file spells out this guard's command line beyond the docstring, so the usage stays where -h prints it instead of a new section.
  • --commits is 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 --commits to this same script, so a test that asserts it is unknown would break when that PR lands. The samples are --frobnicate and -x.
  • The -- separator and the scan over every option position came out of the same fix: rejecting options would otherwise take a path called -foo for a misspelt option, which worked before.

AI-assisted.

…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.
@milas6669

Copy link
Copy Markdown

Tested head 99d1d5327 on Windows 11 (build 26200), Python 3.14 (python -I), clean worktree:

  • tests/test_check_no_game_data.py: 11/11 tests passed in 8.27s
  • Verified -h / --help prints module usage and docstring and exits 0
  • Verified unknown flag (e.g. --frobnicate) prints unknown option --frobnicate to stderr and cleanly exits 2
  • Verified positional paths starting with - can be passed after -- separator
  • Full repository scan (python -I scripts/check_no_game_data.py) exits 0 with zero matches

Clean CLI argument handling without breaking existing path checks or repository verification. Synthetic tests only, no game files. AI-assisted.

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.

2 participants