Added aliases for state list, state mv, and state rm (#1220)

Signed-off-by: Steven Hyland <2knowindeed@gmail.com>
This commit is contained in:
lettucemode
2024-02-01 10:54:09 -05:00
committed by GitHub
parent 7d73f2bbe6
commit d9e023353f
7 changed files with 72 additions and 8 deletions

View File

@@ -370,6 +370,14 @@ func initCommands(
}, nil
},
"state ls": func() (cli.Command, error) {
return &command.AliasCommand{
Command: &command.StateListCommand{
Meta: meta,
},
}, nil
},
"state rm": func() (cli.Command, error) {
return &command.StateRmCommand{
StateMeta: command.StateMeta{
@@ -378,6 +386,16 @@ func initCommands(
}, nil
},
"state remove": func() (cli.Command, error) {
return &command.AliasCommand{
Command: &command.StateRmCommand{
StateMeta: command.StateMeta{
Meta: meta,
},
},
}, nil
},
"state mv": func() (cli.Command, error) {
return &command.StateMvCommand{
StateMeta: command.StateMeta{
@@ -386,6 +404,16 @@ func initCommands(
}, nil
},
"state move": func() (cli.Command, error) {
return &command.AliasCommand{
Command: &command.StateMvCommand{
StateMeta: command.StateMeta{
Meta: meta,
},
},
}, nil
},
"state pull": func() (cli.Command, error) {
return &command.StatePullCommand{
Meta: meta,
@@ -458,3 +486,15 @@ func credentialsSource(config *cliconfig.Config) (auth.CredentialsSource, error)
helperPlugins := pluginDiscovery.FindPlugins("credentials", globalPluginDirs())
return config.CredentialsSource(helperPlugins)
}
func getAliasCommandKeys() []string {
keys := []string{}
for key, cmdFact := range commands {
cmd, _ := cmdFact()
_, ok := cmd.(*command.AliasCommand)
if ok {
keys = append(keys, key)
}
}
return keys
}

View File

@@ -299,11 +299,12 @@ func realMain() int {
// Rebuild the CLI with any modified args.
log.Printf("[INFO] CLI command args: %#v", args)
cliRunner = &cli.CLI{
Name: binName,
Args: args,
Commands: commands,
HelpFunc: helpFunc,
HelpWriter: os.Stdout,
Name: binName,
Args: args,
Commands: commands,
HiddenCommands: getAliasCommandKeys(),
HelpFunc: helpFunc,
HelpWriter: os.Stdout,
Autocomplete: true,
AutocompleteInstall: "install-autocomplete",