Conversation
|
|
||
|
|
||
| class _HelpFlagResolver(argparse.ArgumentParser): | ||
| """Minimal parser that detects --help (and abbreviations like --hel, --he). |
There was a problem hiding this comment.
Allowing abbreviations means that any existing top level parameter that turns into a CLI flag and shares a prefix with help is now superseded by the help system. For example, aws shield associate-health-check has a parameter --health-check-arn Previously, --he arn:123:abc would pass the value arn:123:abc to the HealthCheckArn property:
$ aws shield associate-health-check --he arn:123:abc --protection-id 123456789123456789123456789123456789
However, with this change, this now opens the help. While this example may be mitigated by determining that a value follows the flag, there's no limitation that a top level parameter with a shared prefix to help has to.
| current_cmd([arg, 'help'], None) | ||
| else: | ||
| parser = self.create_parser(command_table) | ||
| parser.parse_known_args(args) |
There was a problem hiding this comment.
aws --region us-west-2 ec2 describe-instances --help prints nothing and exits with 0.
It looks like --region is skipped but not us-west-2 in the loop above which is skipping any token starting with a dash but not its value
| # Bare word that isn't a known command — let the | ||
| # real parser produce the "invalid choice" error. | ||
| if current_cmd is not None: | ||
| current_cmd([arg, 'help'], None) |
There was a problem hiding this comment.
Similarly to my other comment --help doesn't reach help here the way the positional does aws ec2 --region us-east-1 help renders ec2 help and aws ec2 --region us-east-1 --help gives argument operation: Found invalid choice 'us-east-1', because --region is skipped but not its value
| parser.parse_known_args(args) | ||
| return | ||
| if current_cmd is None: | ||
| return self.create_help_command()([], None) |
There was a problem hiding this comment.
Does this work for aliases? aws my-ec2 --help prints nothing and exits 0 for me
There was a problem hiding this comment.
Looks like BaseAliasCommand inherits the base create_help_command() from commands.py, which returns None
| return | ||
| if current_cmd is None: | ||
| return self.create_help_command()([], None) | ||
| help_cmd = current_cmd.create_help_command() |
There was a problem hiding this comment.
aws help --help
aws: [ERROR]: 'ProviderHelpCommand' object has no attribute 'create_help_command'
Every other double-help collapses to one rendering (aws ec2 help --help, aws ec2 --help help, aws ec2 describe-instances help --help) all render the same page as the plain help form, whcih makes me expect was help --help will print aws help, which is what it does today
Issue #, if available:
helpcommand conventions (-h/--helporaws help <command/service>#303Description of changes:
--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.--helpas a global option to the AWS CLI API Reference and the help docs.Description of tests:
--helpon every command type, including value and optional-value options before--help, and--helpbefore a command/operation token.The following commands were tested, either manually or in new automated tests, or both (NOTE: generated by AI and manually verified by me (human)):
helpbehavior--helpbehavioraws help/aws --helpaws ec2 help/aws ec2 --helpaws ec2 run-instances help/aws ec2 run-instances --helpaws s3 help/aws s3 --helpaws s3 ls help/aws s3 ls --helpaws --helaws s3api --help put-object/aws s3api help put-objectaws --help s3api put-object/aws help s3api put-objectaws s3api delete-object --query help/--query --helphelpconsumed as--queryvalue, returnsnullaws s3 cp --acl help/--acl --helpaws s3 cp --expected-size help/--expected-size --helphelpconsumed as value, errors missingpathsaws s3 cp localfile s3://bucket/key help/--helphelpconsumed as positional, errors "Unknown options"aws fake-service help/aws fake-service --helpaws s3api fake-command help/aws s3api fake-command --helpaws s3 fake-command help/aws s3 fake-command --helpBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.