[v2] Add --help parameter for all CLI commands - #10630
Open
kdaily wants to merge 2 commits into
Open
Conversation
Resolve help intent before argument binding so --help renders the same help as the positional help subcommand on every command surface (provider, service, operation, custom/nested commands). New argparser helpers detect and strip the exact --help token; each of the four dispatch layers routes to its existing create_help_command(). --help mirrors the positional help token's position semantics, and is added to _NO_AUTO_PROMPT_ARGS so a help request bypasses auto-prompt. The positional help subcommand is unchanged.
Functional coverage of --help on every surface, including value and optional-value options before --help, and --help appearing before a command or operation token (help resolves at the depth reached, later tokens ignored). Unit coverage for the argparser helpers: - only the exact --help token counts as help - an option's value is not mistaken for a command when routing to top-level help - parsing the tokens before --help still lets --version and Ctrl-C through - descending into a subcommand is decided by parsing rather than string position Updates the structured-error fixture for the extended HELP_BLURB.
kdaily
marked this pull request as ready for review
September 10, 2026 21:14
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.
Issue #, if available:
helpcommand conventions (-h/--helporaws help <command/service>#303Description of changes:
Adds a
--helpparameter that renders the same help as the existinghelpsubcommand, on every command: the top-levelaws, a service (aws ec2 --help), an operation (aws ec2 describe-instances --help), and custom/nested commands (aws configure get --help). Thehelpsubcommand is unchanged.Implementation
Help intent is resolved before normal argument binding.
awscli/argparser.pydetect and strip the exact--helptoken (is_help_option_present,strip_help_options,first_help_option_index).CLIDriver.main,ServiceCommand,ServiceOperation,BasicCommand) routes to its existingcreate_help_command()with--helpstripped. Detecting it up front means a preceding value option cannot consume it.--helpis added to_NO_AUTO_PROMPT_ARGSso a help request bypasses auto-prompt.Behavior
helpsubcommand. Help resolves at the depth reached when--helpappears, and tokens (sub-commands or parameters) after it are ignored, soaws ec2 --help describe-instancesrenders EC2 service help. This is the same asaws ec2 help describe-instances.--helpis help.--hel,--he, and--help=xare not; they fall through as unknown options. This avoids colliding with operation parameters with a shared prefix, like--health-check-type.aws --region ec2 --helprenders top-level help, becauseec2is--region's value.Known limitation
--helpis deliberately absent from the generated global-options synopsis and reference pages. Those are generated fromcli.jsonand pinned bytests/functional/test_globals.py;--helpis intentionally not acli.jsonoption, since that would re-enable prefix matching so--helresolves again. Users find--helpthrough the error text shown on a bad invocation and each command's own help output.Testing
--helpon every command type, including value and optional-value options before--help, and--helpbefore a command/operation token.argparserhelpers, exact-token-only detection, value-aware routing, the pre-help-slice parse, and subcommand-vs-help positioning.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.