Repository navigation
Answer --help and Refuse Unknown Arguments in Every Script - #542
Conversation
Every tracked script now answers --help and -h with its usage on stdout, exits 0, and refuses an argument it does not recognize, before it reads anything. make-release.sh checks its arguments before it sources an environment file, so a flag can no longer start a release. The checks/ gates and the capture/ scripts parse with argparse. The two shell scripts in checks/ and deploy/, and run-wp2hugo.sh, check their own arguments. checks/tests/test_cli_usage.py discovers every tracked executable and runs each with --help, -h, and an unknown flag, under stubbed commands and empty scratch directories, and fails on any effect. A script it does not classify fails too, so a new one is held to the rule. Refs #539 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
redact_media.py and clean_content.py imported Pillow and PyYAML before parsing, so neither answered --help where its module was absent, and the checks/ leg of CI, which has neither, would have skipped both on every run. Each now parses first and reports the missing module after, so the CLI test runs every script with no skip. Refs #539 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both refusals, Pillow missing and Pillow at the wrong pin, now print the same RUN constant rather than two copies of the command. Refs #539 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #542 +/- ##
===========================================
- Coverage 54.07% 53.98% -0.09%
===========================================
Files 12 12
Lines 3390 3412 +22
===========================================
+ Hits 1833 1842 +9
- Misses 1557 1570 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🔵 Needs a closer look
checks/check-live-urls.sh mishandles --help when an extra argument is supplied; the moderate finding should be addressed before approval.
No open issues 🎉
What changed in this PR
This pull request standardizes CLI behavior across tracked scripts: --help and -h provide safe usage output, while unknown arguments are rejected before side effects. It also adds repository-wide regression coverage.
Changes:
- Adds structured argument parsing and early validation across deployment, checks, capture, and media scripts.
- Defers configuration access and optional-dependency errors until after argument parsing.
- Adds executable-discovery tests for help behavior, invalid arguments, external commands, filesystem effects, and repository status.
| File | Summary |
|---|---|
scripts/redact_media.py |
Parses arguments before requiring Pillow. |
deploy/make-release.sh |
Validates arguments before reading deployment configuration. |
checks/url_parity_gate.py |
Adds structured positional-argument parsing. |
checks/tests/test_github_env_gate.py |
Updates test calls for the argument-aware entry point. |
checks/tests/test_cli_usage.py |
Adds repository-wide CLI behavior and side-effect coverage. |
checks/media_redactions_gate.py |
Adds early argument parsing. |
checks/media_metadata_gate.py |
Adds early argument parsing. |
checks/github_env_gate.py |
Adds parsing before GitHub access. |
checks/env_docs_gate.py |
Adds parsing and defers workflow discovery. |
checks/check-live-urls.sh |
Adds help and argument validation; help handling with extra arguments requires correction. |
capture/run-wp2hugo.sh |
Adds early help and unknown-argument handling. |
capture/restructure_content.py |
Replaces manual handling with argparse. |
capture/localize_external.py |
Replaces manual handling with argparse. |
capture/enumerate_media.py |
Parses arguments before reading capture configuration. |
capture/clean_content.py |
Parses before reporting a missing PyYAML dependency. |
capture/classify.py |
Parses arguments before reading capture configuration. |
capture/build_redirects.py |
Uses structured parsing for capture and export options. |
capture/build_golden.py |
Adds early argument parsing before configuration access. |
Review effort: Lite
check-live-urls.sh counted its arguments before it looked for --help, so `extra --help` was refused as an unexpected argument, and run-wp2hugo.sh looked for --help only in the first position. Both now answer help wherever it appears, as make-release.sh and every argparse script already did, and the CLI test runs help after another argument. Refs #539 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
|
Fixed in e0c3d91, answering the review headline on 851dd6b (" |
Summary
Every tracked script answers
--helpand-hwith its usage on stdout and exits 0, and refuses an argument it does not recognize, before it reads anything. This is the fleet's command-line argument rule, applied to the scripts #539 lists and to every other tracked script.deploy/make-release.shchecks its arguments before it sources an environment file.--helpused to be taken as the deploy root and start a release. The empty first argument OPERATIONS.md passes still selects the sourcedDEPLOY_ROOT.checks/check-live-urls.shno longer takes--helpas its base URL, andcapture/run-wp2hugo.shno longer ignores its arguments.checks/gates and thecapture/scripts parse withargparse.env_docs_gate.pyglobs the workflows insidemainrather than at import.scripts/redact_media.pyandcapture/clean_content.pyparse before they report a missing Pillow or PyYAML, so--helpanswers without either.checks/tests/test_cli_usage.pydiscovers every tracked executable and runs each with--help,-h, and--bogus-flag. It fails on a run that calls a stubbed command (git,gh,curl,uv, and others), writes into its scratch home or working directory, or moves the tree's status. A script it does not classify fails too, so a new one is held to the rule.Refs #539
Verification
uvx coverage run -m unittest discover -s testsfromchecks/, the shape CI's lint-only leg runs. Against the base tree it fails on exactly the 15 scripts that broke the rule and passes the 6 that already usedargparse.checks/andscripts/unit suites pass, the latter withscripts/requirements.txtinstalled.851dd6b, built by the changedmake-release.shwith the OPERATIONS.md command, passed the build gates and the full contract, 1296 URLs.Declined local-review finding
checks/tests/test_cli_usage.py, a design finding: the test is a smaller copy of the hub's owntests/test_cli_usage.py. That harness is hub-local, imports hub-only modules, and is not carried, so there is nothing here to extend. Consolidating means the hub carrying it, which is a hub change rather than a Blog one.🤖 Generated with Claude Code