aws / aws/aws-cli

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

Open
#9,446 2 comments 0 reactions 0 assignees View on GitHub
autocomplete feature-request p3
Dominant language
Python
Stars
17.3k
Forks
4.6k
Avg merge
1d 2h
Merged PRs (30d)
13

Description

### Describe the feature

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

```shell
$ aws ec2 in

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

aws help
aws help
aws 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`

```shell
$ aws ec2 in

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

aws help
aws help
aws 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.

```shell
$ aws ec2 in
```

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

```shell
$ 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.