mirror of https://github.com/docker/cli.git
Convert 'docker run' to a cobra command and to use pflags
Move container options into a struct so that tests should pass. Remove unused FlagSet arg from Parse Disable interspersed args on docker run Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
bbefa88a8c
commit
396c0660ab
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/docker/docker/api/client"
|
||||
"github.com/docker/docker/api/client/container"
|
||||
"github.com/docker/docker/api/client/image"
|
||||
"github.com/docker/docker/api/client/volume"
|
||||
"github.com/docker/docker/cli"
|
||||
|
@ -34,8 +35,9 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
|
|||
rootCmd.SetFlagErrorFunc(flagErrorFunc)
|
||||
rootCmd.SetOutput(stdout)
|
||||
rootCmd.AddCommand(
|
||||
volume.NewVolumeCommand(dockerCli),
|
||||
container.NewRunCommand(dockerCli),
|
||||
image.NewSearchCommand(dockerCli),
|
||||
volume.NewVolumeCommand(dockerCli),
|
||||
)
|
||||
|
||||
rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage")
|
||||
|
@ -52,7 +54,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
|
|||
func (c CobraAdaptor) Usage() []cli.Command {
|
||||
cmds := []cli.Command{}
|
||||
for _, cmd := range c.rootCmd.Commands() {
|
||||
cmds = append(cmds, cli.Command{Name: cmd.Use, Description: cmd.Short})
|
||||
cmds = append(cmds, cli.Command{Name: cmd.Name(), Description: cmd.Short})
|
||||
}
|
||||
return cmds
|
||||
}
|
||||
|
|
1
usage.go
1
usage.go
|
@ -37,7 +37,6 @@ var DockerCommandUsage = []Command{
|
|||
{"restart", "Restart a container"},
|
||||
{"rm", "Remove one or more containers"},
|
||||
{"rmi", "Remove one or more images"},
|
||||
{"run", "Run a command in a new container"},
|
||||
{"save", "Save one or more images to a tar archive"},
|
||||
{"start", "Start one or more stopped containers"},
|
||||
{"stats", "Display a live stream of container(s) resource usage statistics"},
|
||||
|
|
Loading…
Reference in New Issue