Browse code

Fix create command flags

Any command that expects extra flags after positional args needs to set flags.SetInterspersed(false).

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/06/07 21:11:11
Showing 2 changed files
... ...
@@ -46,6 +46,8 @@ func NewCreateCommand(dockerCli *client.DockerCli) *cobra.Command {
46 46
 	cmd.SetFlagErrorFunc(flagErrorFunc)
47 47
 
48 48
 	flags := cmd.Flags()
49
+	flags.SetInterspersed(false)
50
+
49 51
 	flags.StringVar(&opts.name, "name", "", "Assign a name to the container")
50 52
 
51 53
 	// Add an explicit help that doesn't have a `-h` to prevent the conflict
... ...
@@ -25,7 +25,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
25 25
 	if daemonPlatform == "windows" {
26 26
 		c.Skip("Fails on Windows CI")
27 27
 	}
28
-	out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space")
28
+	out, _ := dockerCmd(c, "create", "busybox", "command", "arg1", "arg2", "arg with space", "-c", "flags")
29 29
 
30 30
 	cleanedContainerID := strings.TrimSpace(out)
31 31
 
... ...
@@ -47,7 +47,7 @@ func (s *DockerSuite) TestCreateArgs(c *check.C) {
47 47
 	c.Assert(string(cont.Path), checker.Equals, "command", check.Commentf("Unexpected container path. Expected command, received: %s", cont.Path))
48 48
 
49 49
 	b := false
50
-	expected := []string{"arg1", "arg2", "arg with space"}
50
+	expected := []string{"arg1", "arg2", "arg with space", "-c", "flags"}
51 51
 	for i, arg := range expected {
52 52
 		if arg != cont.Args[i] {
53 53
 			b = true