Skip to content

Hold an Unlisted CLI That Needs an Argument to Refusing the Unknown Flag Itself #2948

Closed

Description

@ptr727

After #2944 the CLI usage gate (tests/test_cli_usage.py) holds a script that needs a subcommand or positional arguments to a refusal of --bogus-flag only where the script is listed in BEFORE_FLAG, which supplies arguments that satisfy its parser. A new script that needs an argument and is not listed is held only to a non-zero exit with no effect, so one that merely warns on the flag and then stops on the missing argument passes.

A word list over the output does not close this: the repository's own missing-argument refusals use wording such as "No command given (expected apply or check)" and "--repo needs a path", and a list of such phrases only grows. One direction that would close it structurally: a declared field, for example a per-script marker that the script takes no required argument, would let the gate refuse an entry point that is neither listed in BEFORE_FLAG nor marked. Running each unlisted entry point with no arguments to find out is not safe, since an unlisted script's default mode may do real work. Comparing the output for two different unknown flags does not separate the cases either, since a warning names whichever flag it was given.

Found by the local review pass on #2944, whose docstring states this limit.

Activity

  1. added
    gate
    introduced
    on Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gateintroduced

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions