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:
Daniel Nephin 2016-05-31 16:49:32 -07:00 committed by Vincent Demeester
parent bbefa88a8c
commit 396c0660ab
2 changed files with 4 additions and 3 deletions

View File

@ -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
}

View File

@ -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"},