mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-19 17:59:05 -05:00
Added aliases for state list, state mv, and state rm (#1220)
Signed-off-by: Steven Hyland <2knowindeed@gmail.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user