diff --git a/commands/create.go b/commands/create.go index 43b5daee9f..7f7ee8483d 100644 --- a/commands/create.go +++ b/commands/create.go @@ -1,7 +1,6 @@ package commands import ( - "errors" "fmt" "os" "path/filepath" @@ -21,10 +20,6 @@ import ( "github.com/docker/machine/libmachine/swarm" ) -var ( - ErrDriverNotRecognized = errors.New("Driver not recognized.") -) - func cmdCreate(c *cli.Context) { var ( driver drivers.Driver @@ -56,6 +51,10 @@ func cmdCreate(c *cli.Context) { log.Fatal("You must specify a machine name") } + if len(c.Args()) > 1 { + log.Fatalf("Invalid command line. Found extra arguments %v", c.Args()[1:]) + } + validName := host.ValidateHostName(name) if !validName { log.Fatal("Error creating machine: ", mcnerror.ErrInvalidHostname) diff --git a/test/integration/cli/create-rm.bats b/test/integration/cli/create-rm.bats index bb8f941a44..ba365d84cd 100644 --- a/test/integration/cli/create-rm.bats +++ b/test/integration/cli/create-rm.bats @@ -52,10 +52,10 @@ load ${BASE_TEST_DIR}/helpers.bash [[ ${lines[0]} == "Error creating machine: Machine A already exists" ]] } -@test "none: extraneous argument is ignored in name 'machine create -d none --url none a foo'" { - run machine create -d none a foo +@test "none: fail with extra argument 'machine create -d none --url none a extra'" { + run machine create -d none --url none a extra [ "$status" -eq 1 ] - [[ ${lines[0]} == "Host already exists: \"a\"" ]] + [[ ${lines[0]} == "Invalid command line. Found extra arguments [extra]" ]] } @test "none: create with weird but valid name succeeds 'machine create -d none --url none 0'" {