Shell / Tab completion for atmos stacks and components
Have a question? Please checkout our Slack Community or visit our Slack Archive.
Describe the Feature
Tab completion for atmos commands
Expected Behavior
$ atmos<tab>
helm helmfile help istioctl stack terraform vendor version workflow
$ atmos terraform<tab>
apply backend clean console deploy destroy import init output plan show workspace
$ atmos terraform plan<tab>
tfstate-backend aws-sso github-runners # etc
$ atmos terraform plan github-runners --stack<tab>
gbl-root gbl-prod gbl-staging
Use Case
I want the command and stacks to complete using tab instead of having to type it in each time
Describe Ideal Solution
It's implemented
Alternatives Considered
None
Additional Context
- https://stackoverflow.com/questions/5570795/how-does-bash-tab-completion-work
- https://github.com/perlpunk/shell-completions
I did notice there is a new completion subcommand.
⨠eval $(atmos completion bash)
⨠atmos<tab>
completion (generate the autocompletion script for the specified shell)
describe (describe)
helmfile (helmfile command)
help (Help about any command)
terraform (terraform command)
version (version command)
This seems to be off
⨠atmos terraform <tab>
--stack -s generate (generate)
That should show plan/apply/deploy/destroy
This returns a - when hitting tab instead of showing the list of components
⨠atmos terraform plan <tab>
This returns another - when it should show the list of stacks
⨠atmos terraform plan efs --stack <tab>
@mcalhoun
I reopened this ticket because I was hoping we could do something like this
# get components
atmos terraform plan <tab>
# get root stack
atmos terraform plan ecr --stack <tab>
Yeah, I just realized I only implemented the base-level (atmos commands) and not stack completion. Figuring out how to do that will be a bit more tricky.
"real" (not abstract) component completion and root stack completion would be very handy here.
I also noticed that subcommands are missing.
✗ atmos terraform<tab>
generate -- Execute 'terraform generate' commands
provision -- This command provisions terraform components
I was expecting plan, deploy, apply, etc
Here's a way to get all the stacks using yq
✗ atmos describe stacks | yq e '. | keys'
- gbl-corp
- gbl-identity
- gbl-root
...
An even easier way is using it natively in atmos
✗ atmos list stacks
gbl-corp
gbl-identity
gbl-root
Here's how to get all the real components using yq
✗ atmos describe stacks | yq e '. | to_entries | .[].value.components.terraform | with_entries(select(.value.metadata.type != "abstract")) | keys' | grep -v '\[\]' | sort | uniq
- aws-team-roles
- aws-teams
- account
- account-map
- aws-team-roles
- github-oidc-provider
- vpc