Closed nitrocode closed 8 months ago
@nitrocode thanks!
Atmos uses Cobra
to parse the command line arguments and flags.
Cobra
supports adding aliases to a subcommand, for example terraform
can be tf
, or terraform plan
can be tf pl
(not sure if pl
is better than just plan
).
Cobra
can't add aliases for a combination of subcommands, so something like atmos tfpl
(for atmos terraform plan
) is not supported.
And, the aliases you mentioned above is not supported as well. In fact, something like aagrc
on the command line will be parsed by the shell before the shell executes the atmos
binary, so Atmos/Cobra will not even see it.
Aliases like that is not an Atmos feature, it's a shell feature (e.g. in bash
, alias alias_name="command_to_run"
).
To execute the atmos
binary, you have to run atmos
on the command line (or any shell alias for it).
Thank you
Thanks for considering @aknysh. I meant shell aliases, not golang cobra aliases, but that would be a nifty feature too.
E.g. This works for me
alias aagrc="atmos atlantis generate repo-config"
I use a few of these locally but I've created the aliases manually. I'd rather use a zsh plug-in like the one for terraform which populates my shell aliases. It also creates new aliases for me when terraform releases a new subcommand.
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/terraform
We discussed internally and are leaning towards introducing command aliases via the atmos.yaml
so individuals can customize as they see fit. I think it will be too hard to agree on a convention for aliasing that will meet everyone's requirements.
e.g.
In the atmos.yaml
, you would add:
aliases:
tp: terraform plan
ta: terraform apply
agrc: atlantis generate repo-config
Then to use the aliases, you would run atmos tp
as a shortcut for atmos terraform plan
[!TIP] Use Shell Aliases In your shell, you can do
alias a=atmos
, then runa tp
as a shortcut foratmos terraform plan
Awesome, tyvm
aliases:
h: help
v: version
c: completion
da: describe affected
dcm: describe component
dcn: describe config
dd: describe dependents
ds: describe stacks
t: terraform
tc: terraform clean
td: terraform deploy
tgb: terraform generate backend
tgbs: terraform generate backends
tgv: terraform generate varfile
tgvs: terraform generate varfiles
ts: terraform shell
tw: terraform workspace
hf: helmfile
hgv: helmfile generate varfile
vc: validate component
vs: validate stacks
vp: vendor pull
w: workflow
aeuk: aws eks update-kubeconfig
agrc: atlantis generate repo-config
Describe the Feature
For each of these cheatsheet commands, an alias can be used
https://github.com/cloudposse/atmos/blob/master/website/docs/cli/cheatsheet.md
e.g.
atmos help
ahp
atmos version
av
atmos completion
ac
atmos describe affected
ada
atmos describe component
adcm
atmos describe config
adcn
atmos describe dependents
add
atmos describe stacks
ads
atmos terraform
at
atmos terraform clean
atc
atmos terraform deploy
atd
atmos terraform generate backend
atgb
atmos terraform generate backends
atgbs
atmos terraform generate varfile
atgv
atmos terraform generate varfiles
atgvs
atmos terraform shell
ats
atmos terraform workspace
atw
atmos helmfile
ah
atmos helmfile generate varfile
ahgv
atmos validate component
avc
atmos validate stacks
avs
atmos vendor pull
avp
atmos workflow
aw
atmos aws eks update-kubeconfig
aaeuk
atmos atlantis generate repo-config
aagrc
Expected Behavior
Install aliases using an atmos command
Or
A zsh plugin that creates all the aliases
Use Case
Less verbose commands
Describe Ideal Solution
See Expected Behavior
Alternatives Considered
Creating my own aliases or my own zsh plugin
Additional Context
N/A