diff --git a/commands/inspect.go b/commands/inspect.go index 0ce219507a..69e4ec64ac 100644 --- a/commands/inspect.go +++ b/commands/inspect.go @@ -23,6 +23,11 @@ var funcMap = template.FuncMap{ } func cmdInspect(c *cli.Context) { + if len(c.Args()) == 0 { + cli.ShowCommandHelp(c, "inspect") + log.Fatal("You must specify a machine name") + } + tmplString := c.String("format") if tmplString != "" { var tmpl *template.Template diff --git a/commands/status.go b/commands/status.go index f2ca12b3de..eb52acffea 100644 --- a/commands/status.go +++ b/commands/status.go @@ -1,12 +1,14 @@ package commands import ( - "github.com/docker/machine/libmachine/log" - "github.com/codegangsta/cli" + "github.com/docker/machine/libmachine/log" ) func cmdStatus(c *cli.Context) { + if len(c.Args()) != 1 { + log.Fatal(ErrExpectedOneMachine) + } host := getFirstArgHost(c) currentState, err := host.Driver.GetState() if err != nil { diff --git a/commands/url.go b/commands/url.go index 2d28195890..9881f0f32c 100644 --- a/commands/url.go +++ b/commands/url.go @@ -3,12 +3,14 @@ package commands import ( "fmt" - "github.com/docker/machine/libmachine/log" - "github.com/codegangsta/cli" + "github.com/docker/machine/libmachine/log" ) func cmdUrl(c *cli.Context) { + if len(c.Args()) != 1 { + log.Fatal(ErrExpectedOneMachine) + } url, err := getFirstArgHost(c).GetURL() if err != nil { log.Fatal(err) diff --git a/test/integration/cli/inspect.bats b/test/integration/cli/inspect.bats new file mode 100644 index 0000000000..5777c25824 --- /dev/null +++ b/test/integration/cli/inspect.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ${BASE_TEST_DIR}/helpers.bash + +@test "inspect: show error in case of no args" { + run machine inspect + [ "$status" -eq 1 ] + [[ ${output} == *"must specify a machine name"* ]] +} diff --git a/test/integration/cli/status.bats b/test/integration/cli/status.bats new file mode 100644 index 0000000000..329e48145c --- /dev/null +++ b/test/integration/cli/status.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ${BASE_TEST_DIR}/helpers.bash + +@test "status: show error in case of no args" { + run machine inspect + [ "$status" -eq 1 ] + [[ ${output} == *"must specify a machine name"* ]] +} diff --git a/test/integration/cli/url.bats b/test/integration/cli/url.bats new file mode 100644 index 0000000000..727454d941 --- /dev/null +++ b/test/integration/cli/url.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load ${BASE_TEST_DIR}/helpers.bash + +@test "url: show error in case of no args" { + run machine inspect + [ "$status" -eq 1 ] + [[ ${output} == *"must specify a machine name"* ]] +}