Skip to content

aws_completer does not auto complete command aliases, even though aliases are displayed as valid choices in error message #9446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks
isleshocky77 opened this issue Apr 16, 2025 · 0 comments
Labels
feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.

Comments

@isleshocky77
Copy link

isleshocky77 commented Apr 16, 2025

Describe the feature

Currently, if you were to type an invalid subcommand, you get back a list of valid subcommands

$ aws ec2 in

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: argument operation: Invalid choice, valid choices are:

accept-address-transfer                  | accept-reserved-instances-exchange-quote
accept-transit-gateway-multicast-domain-associations | accept-transit-gateway-peering-attachment 
[...]

This list actually includes custom aliases defined in ~/.aws/cli/alias

$ aws ec2 in

usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:

  aws help
  aws <command> help
  aws <command> <subcommand> help

aws: error: argument operation: Invalid choice, valid choices are:

accept-address-transfer                  | accept-reserved-instances-exchange-quote
accept-transit-gateway-multicast-domain-associations | accept-transit-gateway-peering-attachment
accept-transit-gateway-vpc-attachment    | accept-vpc-endpoint-connections         
[....]
withdraw-byoip-cidr                      | wait                                    
instances-running-table                  | instances-stopped-table                 
instances-status                         | help                                    

$ 

However, aws_autocomplete does not seem to have available the aliases to be auto completed. The below command does not display any of the instances-* commands as shown in the error message above.

$ aws ec2 in<tab>

The aws_completer command doesn't include the alias in it's results

$ COMP_LINE="aws ec2 i" aws_completer 
import-client-vpn-client-certificate-revocation-list
import-image
import-key-pair
import-snapshot
$

Use Case

It is much faster to use autocomplete to complete long commands as well as to remind oneself of what commands exist based on a known prefix. This should include custom aliases which are created in the ~/.aws/cli/alias file.

Proposed Solution

Make sure the same method of building the list of available subcommands in error messages is used by aws_completer to build available command and subcommand choices including aliases from ~/.aws/cli/alias.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CLI version used

aws-cli/2.17.32 Python/3.11.9 Linux/6.11.0-21-generic exe/x86_64.ubuntu.24

Environment details (OS name and version, etc.)

Ubuntu 24.04.2 LTS

@isleshocky77 isleshocky77 added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

1 participant