From 3e1b9350f58802cbfd5074e855252f09ef63267b Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 19 Sep 2016 14:31:53 -0400 Subject: [PATCH] Make all the experimental subcommand consistent. Signed-off-by: Daniel Nephin --- command/checkpoint/cmd.go | 5 ++-- command/checkpoint/cmd_experimental.go | 7 ++--- command/commands/commands.go | 4 +-- command/plugin/cmd.go | 3 +- command/plugin/cmd_experimental.go | 5 ++-- command/stack/cmd.go | 31 ++++---------------- command/stack/cmd_experimental.go | 39 ++++++++++++++++++++++++++ command/stack/cmd_stub.go | 18 ------------ 8 files changed, 56 insertions(+), 56 deletions(-) create mode 100644 command/stack/cmd_experimental.go delete mode 100644 command/stack/cmd_stub.go diff --git a/command/checkpoint/cmd.go b/command/checkpoint/cmd.go index bc8224a2ff..7c3950bba8 100644 --- a/command/checkpoint/cmd.go +++ b/command/checkpoint/cmd.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" ) -// NewCheckpointCommand appends the `checkpoint` subcommands to rootCmd (only in experimental) -func NewCheckpointCommand(rootCmd *cobra.Command, dockerCli *command.DockerCli) { +// NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental) +func NewCheckpointCommand(dockerCli *command.DockerCli) *cobra.Command { + return &cobra.Command{} } diff --git a/command/checkpoint/cmd_experimental.go b/command/checkpoint/cmd_experimental.go index c05d3ded40..3c89545778 100644 --- a/command/checkpoint/cmd_experimental.go +++ b/command/checkpoint/cmd_experimental.go @@ -11,8 +11,8 @@ import ( "github.com/docker/docker/cli/command" ) -// NewCheckpointCommand appends the `checkpoint` subcommands to rootCmd -func NewCheckpointCommand(rootCmd *cobra.Command, dockerCli *command.DockerCli) { +// NewCheckpointCommand returns the `checkpoint` subcommand (only in experimental) +func NewCheckpointCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "checkpoint", Short: "Manage checkpoints", @@ -26,6 +26,5 @@ func NewCheckpointCommand(rootCmd *cobra.Command, dockerCli *command.DockerCli) newListCommand(dockerCli), newRemoveCommand(dockerCli), ) - - rootCmd.AddCommand(cmd) + return cmd } diff --git a/command/commands/commands.go b/command/commands/commands.go index d618233997..3e8aa25af2 100644 --- a/command/commands/commands.go +++ b/command/commands/commands.go @@ -71,9 +71,9 @@ func AddCommands(cmd *cobra.Command, dockerCli *command.DockerCli) { hide(image.NewSaveCommand(dockerCli)), hide(image.NewTagCommand(dockerCli)), hide(system.NewInspectCommand(dockerCli)), + checkpoint.NewCheckpointCommand(dockerCli), + plugin.NewPluginCommand(dockerCli), ) - checkpoint.NewCheckpointCommand(cmd, dockerCli) - plugin.NewPluginCommand(cmd, dockerCli) } func hide(cmd *cobra.Command) *cobra.Command { diff --git a/command/plugin/cmd.go b/command/plugin/cmd.go index 67d0d5031c..10074218dd 100644 --- a/command/plugin/cmd.go +++ b/command/plugin/cmd.go @@ -8,5 +8,6 @@ import ( ) // NewPluginCommand returns a cobra command for `plugin` subcommands -func NewPluginCommand(cmd *cobra.Command, dockerCli *command.DockerCli) { +func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command { + return &cobra.Command{} } diff --git a/command/plugin/cmd_experimental.go b/command/plugin/cmd_experimental.go index 33c1c93acb..8bb3416097 100644 --- a/command/plugin/cmd_experimental.go +++ b/command/plugin/cmd_experimental.go @@ -11,7 +11,7 @@ import ( ) // NewPluginCommand returns a cobra command for `plugin` subcommands -func NewPluginCommand(rootCmd *cobra.Command, dockerCli *command.DockerCli) { +func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command { cmd := &cobra.Command{ Use: "plugin", Short: "Manage plugins", @@ -31,6 +31,5 @@ func NewPluginCommand(rootCmd *cobra.Command, dockerCli *command.DockerCli) { newSetCommand(dockerCli), newPushCommand(dockerCli), ) - - rootCmd.AddCommand(cmd) + return cmd } diff --git a/command/stack/cmd.go b/command/stack/cmd.go index 22a2334419..51cb2d1bcf 100644 --- a/command/stack/cmd.go +++ b/command/stack/cmd.go @@ -1,39 +1,18 @@ -// +build experimental +// +build !experimental package stack import ( - "fmt" - - "github.com/docker/docker/cli" "github.com/docker/docker/cli/command" "github.com/spf13/cobra" ) -// NewStackCommand returns a cobra command for `stack` subcommands +// NewStackCommand returns no command func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { - cmd := &cobra.Command{ - Use: "stack", - Short: "Manage stacks", - Args: cli.NoArgs, - Run: func(cmd *cobra.Command, args []string) { - fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) - }, - } - cmd.AddCommand( - newConfigCommand(dockerCli), - newDeployCommand(dockerCli), - newRemoveCommand(dockerCli), - newServicesCommand(dockerCli), - newPsCommand(dockerCli), - ) - return cmd + return &cobra.Command{} } -// NewTopLevelDeployCommand returns a command for `docker deploy` +// NewTopLevelDeployCommand returns no command func NewTopLevelDeployCommand(dockerCli *command.DockerCli) *cobra.Command { - cmd := *newDeployCommand(dockerCli) - // Remove the aliases at the top level - cmd.Aliases = []string{} - return &cmd + return &cobra.Command{} } diff --git a/command/stack/cmd_experimental.go b/command/stack/cmd_experimental.go new file mode 100644 index 0000000000..d459e0a9a1 --- /dev/null +++ b/command/stack/cmd_experimental.go @@ -0,0 +1,39 @@ +// +build experimental + +package stack + +import ( + "fmt" + + "github.com/docker/docker/cli" + "github.com/docker/docker/cli/command" + "github.com/spf13/cobra" +) + +// NewStackCommand returns a cobra command for `stack` subcommands +func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { + cmd := &cobra.Command{ + Use: "stack", + Short: "Manage Docker stacks", + Args: cli.NoArgs, + Run: func(cmd *cobra.Command, args []string) { + fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString()) + }, + } + cmd.AddCommand( + newConfigCommand(dockerCli), + newDeployCommand(dockerCli), + newRemoveCommand(dockerCli), + newServicesCommand(dockerCli), + newPsCommand(dockerCli), + ) + return cmd +} + +// NewTopLevelDeployCommand returns a command for `docker deploy` +func NewTopLevelDeployCommand(dockerCli *command.DockerCli) *cobra.Command { + cmd := newDeployCommand(dockerCli) + // Remove the aliases at the top level + cmd.Aliases = []string{} + return cmd +} diff --git a/command/stack/cmd_stub.go b/command/stack/cmd_stub.go deleted file mode 100644 index 51cb2d1bcf..0000000000 --- a/command/stack/cmd_stub.go +++ /dev/null @@ -1,18 +0,0 @@ -// +build !experimental - -package stack - -import ( - "github.com/docker/docker/cli/command" - "github.com/spf13/cobra" -) - -// NewStackCommand returns no command -func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command { - return &cobra.Command{} -} - -// NewTopLevelDeployCommand returns no command -func NewTopLevelDeployCommand(dockerCli *command.DockerCli) *cobra.Command { - return &cobra.Command{} -}