Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Victor Vieux 2016-11-17 10:54:10 -08:00
Родитель 0a5a41a438
Коммит bf95472105
14 изменённых файлов: 23 добавлений и 54 удалений

Просмотреть файл

@ -12,10 +12,7 @@ func NewCheckpointCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "checkpoint", Use: "checkpoint",
Short: "Manage checkpoints", Short: "Manage checkpoints",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
Tags: map[string]string{"experimental": "", "version": "1.25"}, Tags: map[string]string{"experimental": "", "version": "1.25"},
} }
cmd.AddCommand( cmd.AddCommand(

Просмотреть файл

@ -20,6 +20,7 @@ import (
dopts "github.com/docker/docker/opts" dopts "github.com/docker/docker/opts"
"github.com/docker/go-connections/sockets" "github.com/docker/go-connections/sockets"
"github.com/docker/go-connections/tlsconfig" "github.com/docker/go-connections/tlsconfig"
"github.com/spf13/cobra"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -73,6 +74,13 @@ func (cli *DockerCli) In() *InStream {
return cli.in return cli.in
} }
// ShowHelp shows the command help.
func (cli *DockerCli) ShowHelp(cmd *cobra.Command, args []string) error {
cmd.SetOutput(cli.err)
cmd.HelpFunc()(cmd, args)
return nil
}
// ConfigFile returns the ConfigFile // ConfigFile returns the ConfigFile
func (cli *DockerCli) ConfigFile() *configfile.ConfigFile { func (cli *DockerCli) ConfigFile() *configfile.ConfigFile {
return cli.configFile return cli.configFile

Просмотреть файл

@ -13,10 +13,7 @@ func NewContainerCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "container", Use: "container",
Short: "Manage containers", Short: "Manage containers",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
NewAttachCommand(dockerCli), NewAttachCommand(dockerCli),

Просмотреть файл

@ -13,10 +13,7 @@ func NewImageCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "image", Use: "image",
Short: "Manage images", Short: "Manage images",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
NewBuildCommand(dockerCli), NewBuildCommand(dockerCli),

Просмотреть файл

@ -13,10 +13,7 @@ func NewNetworkCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "network", Use: "network",
Short: "Manage networks", Short: "Manage networks",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
newConnectCommand(dockerCli), newConnectCommand(dockerCli),

Просмотреть файл

@ -14,10 +14,7 @@ func NewNodeCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "node", Use: "node",
Short: "Manage Swarm nodes", Short: "Manage Swarm nodes",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
newDemoteCommand(dockerCli), newDemoteCommand(dockerCli),

Просмотреть файл

@ -12,10 +12,7 @@ func NewPluginCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "plugin", Use: "plugin",
Short: "Manage plugins", Short: "Manage plugins",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(

Просмотреть файл

@ -1,8 +1,6 @@
package secret package secret
import ( import (
"fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/docker/docker/cli" "github.com/docker/docker/cli"
@ -15,9 +13,7 @@ func NewSecretCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "secret", Use: "secret",
Short: "Manage Docker secrets", Short: "Manage Docker secrets",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
fmt.Fprintf(dockerCli.Err(), "\n"+cmd.UsageString())
},
} }
cmd.AddCommand( cmd.AddCommand(
newSecretListCommand(dockerCli), newSecretListCommand(dockerCli),

Просмотреть файл

@ -13,10 +13,7 @@ func NewServiceCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "service", Use: "service",
Short: "Manage services", Short: "Manage services",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
newCreateCommand(dockerCli), newCreateCommand(dockerCli),

Просмотреть файл

@ -12,10 +12,7 @@ func NewStackCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "stack", Use: "stack",
Short: "Manage Docker stacks", Short: "Manage Docker stacks",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
Tags: map[string]string{"experimental": "", "version": "1.25"}, Tags: map[string]string{"experimental": "", "version": "1.25"},
} }
cmd.AddCommand( cmd.AddCommand(

Просмотреть файл

@ -13,10 +13,7 @@ func NewSwarmCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "swarm", Use: "swarm",
Short: "Manage Swarm", Short: "Manage Swarm",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
newInitCommand(dockerCli), newInitCommand(dockerCli),

Просмотреть файл

@ -13,10 +13,7 @@ func NewSystemCommand(dockerCli *command.DockerCli) *cobra.Command {
Use: "system", Use: "system",
Short: "Manage Docker", Short: "Manage Docker",
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
NewEventsCommand(dockerCli), NewEventsCommand(dockerCli),

Просмотреть файл

@ -14,10 +14,7 @@ func NewVolumeCommand(dockerCli *command.DockerCli) *cobra.Command {
Short: "Manage volumes", Short: "Manage volumes",
Long: volumeDescription, Long: volumeDescription,
Args: cli.NoArgs, Args: cli.NoArgs,
Run: func(cmd *cobra.Command, args []string) { RunE: dockerCli.ShowHelp,
cmd.SetOutput(dockerCli.Err())
cmd.HelpFunc()(cmd, args)
},
} }
cmd.AddCommand( cmd.AddCommand(
newCreateCommand(dockerCli), newCreateCommand(dockerCli),

Просмотреть файл

@ -34,9 +34,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
showVersion() showVersion()
return nil return nil
} }
cmd.SetOutput(dockerCli.Err()) return dockerCli.ShowHelp(cmd, args)
cmd.HelpFunc()(cmd, args)
return nil
}, },
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
// daemon command is special, we redirect directly to another binary // daemon command is special, we redirect directly to another binary