diff --git a/command/commands.go b/command/commands.go index 75e17cdf6b..1d4fa2c159 100644 --- a/command/commands.go +++ b/command/commands.go @@ -28,6 +28,7 @@ import ( "github.com/hashicorp/consul/command/members" "github.com/hashicorp/consul/command/monitor" "github.com/hashicorp/consul/command/oper" + "github.com/hashicorp/consul/command/operauto" "github.com/hashicorp/consul/command/operraft" "github.com/hashicorp/consul/command/operraftlist" "github.com/hashicorp/consul/command/operraftremove" @@ -150,12 +151,7 @@ func init() { }, "operator autopilot": func() (cli.Command, error) { - return &OperatorAutopilotCommand{ - BaseCommand: BaseCommand{ - Flags: FlagSetNone, - UI: ui, - }, - }, nil + return operauto.New(), nil }, "operator autopilot get-config": func() (cli.Command, error) { diff --git a/command/operator_autopilot.go b/command/operator_autopilot.go deleted file mode 100644 index acd1feb509..0000000000 --- a/command/operator_autopilot.go +++ /dev/null @@ -1,28 +0,0 @@ -package command - -import ( - "github.com/mitchellh/cli" -) - -type OperatorAutopilotCommand struct { - BaseCommand -} - -func (c *OperatorAutopilotCommand) Help() string { - c.InitFlagSet() - return c.HelpCommand(` -Usage: consul operator autopilot [options] - -The Autopilot operator command is used to interact with Consul's Autopilot -subsystem. The command can be used to view or modify the current configuration. - -`) -} - -func (c *OperatorAutopilotCommand) Synopsis() string { - return "Provides tools for modifying Autopilot configuration" -} - -func (c *OperatorAutopilotCommand) Run(args []string) int { - return cli.RunResultHelp -} diff --git a/command/operator_autopilot_test.go b/command/operator_autopilot_test.go deleted file mode 100644 index 5bff69291c..0000000000 --- a/command/operator_autopilot_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package command - -import ( - "testing" - - "github.com/mitchellh/cli" -) - -func TestOperator_Autopilot_Implements(t *testing.T) { - t.Parallel() - var _ cli.Command = &OperatorAutopilotCommand{} -} diff --git a/command/operauto/operator_autopilot.go b/command/operauto/operator_autopilot.go new file mode 100644 index 0000000000..87f2cb51b5 --- /dev/null +++ b/command/operauto/operator_autopilot.go @@ -0,0 +1,28 @@ +package operauto + +import ( + "github.com/mitchellh/cli" +) + +func New() *cmd { + return &cmd{} +} + +type cmd struct{} + +func (c *cmd) Run(args []string) int { + return cli.RunResultHelp +} + +func (c *cmd) Synopsis() string { + return "Provides tools for modifying Autopilot configuration" +} + +func (c *cmd) Help() string { + s := `Usage: consul operator autopilot [options] + +The Autopilot operator command is used to interact with Consul's Autopilot +subsystem. The command can be used to view or modify the current configuration.` + + return s +} diff --git a/command/operauto/operator_autopilot_test.go b/command/operauto/operator_autopilot_test.go new file mode 100644 index 0000000000..02847f2a3e --- /dev/null +++ b/command/operauto/operator_autopilot_test.go @@ -0,0 +1,13 @@ +package operauto + +import ( + "strings" + "testing" +) + +func TestOperatorAutopilotCommand_noTabs(t *testing.T) { + t.Parallel() + if strings.ContainsRune(New().Help(), '\t') { + t.Fatal("usage has tabs") + } +}