diff --git a/commands.go b/commands.go index 7040cbb33f..a63dd527ed 100644 --- a/commands.go +++ b/commands.go @@ -26,6 +26,7 @@ const runningInAutomationEnvName = "TF_IN_AUTOMATION" // Commands is the mapping of all the available Terraform commands. var Commands map[string]cli.CommandFactory var PlumbingCommands map[string]struct{} +var HiddenCommands map[string]struct{} // Ui is the cli.Ui used for communicating to the outside world. var Ui cli.Ui @@ -96,9 +97,14 @@ func initCommands( PlumbingCommands = map[string]struct{}{ "state": struct{}{}, // includes all subcommands "force-unlock": struct{}{}, - "push": struct{}{}, - "0.12upgrade": struct{}{}, - "0.13upgrade": struct{}{}, + } + + HiddenCommands = map[string]struct{}{ + "0.12upgrade": struct{}{}, + "0.13upgrade": struct{}{}, + "env": struct{}{}, + "internal-plugin": struct{}{}, + "push": struct{}{}, } Commands = map[string]cli.CommandFactory{ diff --git a/help.go b/help.go index e020edea9c..6de48cd355 100644 --- a/help.go +++ b/help.go @@ -17,6 +17,12 @@ func helpFunc(commands map[string]cli.CommandFactory) string { plumbing := make(map[string]cli.CommandFactory) maxKeyLen := 0 for key, f := range commands { + if _, ok := HiddenCommands[key]; ok { + // We don't consider hidden commands when deciding the + // maximum command length. + continue + } + if len(key) > maxKeyLen { maxKeyLen = len(key) } @@ -65,11 +71,6 @@ func listCommands(commands map[string]cli.CommandFactory, maxKeyLen int) string // key length so they can be aligned properly. keys := make([]string, 0, len(commands)) for key, _ := range commands { - // This is an internal command that users should never call directly so - // we will hide it from the command listing. - if key == "internal-plugin" { - continue - } keys = append(keys, key) } sort.Strings(keys)