diff --git a/commands/commands.go b/commands/commands.go index a9c2a10f6d..397a8d1d9a 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -384,6 +384,12 @@ var Commands = []cli.Command{ Description: "Argument(s) are one or more machine names.", Action: cmdStart, }, + { + Name: "status", + Usage: "Get the status of a machine", + Description: "Argument is a machine name.", + Action: cmdStatus, + }, { Name: "stop", Usage: "Stop a machine", diff --git a/commands/status.go b/commands/status.go new file mode 100644 index 0000000000..1247d31235 --- /dev/null +++ b/commands/status.go @@ -0,0 +1,16 @@ +package commands + +import ( + "github.com/docker/machine/log" + + "github.com/codegangsta/cli" +) + +func cmdStatus(c *cli.Context) { + host := getHost(c) + currentState, err := host.Driver.GetState() + if err != nil { + log.Errorf("error getting state for host %s: %s", host.Name, err) + } + log.Info(currentState) +} diff --git a/commands/status_test.go b/commands/status_test.go new file mode 100644 index 0000000000..cdff10da75 --- /dev/null +++ b/commands/status_test.go @@ -0,0 +1 @@ +package commands diff --git a/docs/reference/index.md b/docs/reference/index.md index fa4515862b..3976e2a84c 100644 --- a/docs/reference/index.md +++ b/docs/reference/index.md @@ -27,6 +27,7 @@ parent="smn_machine_ref" * [scp](scp.md) * [ssh](ssh.md) * [start](start.md) +* [status](status.md) * [stop](stop.md) * [upgrade](upgrade.md) -* [url](url.md) \ No newline at end of file +* [url](url.md) diff --git a/docs/reference/status.md b/docs/reference/status.md new file mode 100644 index 0000000000..815800c934 --- /dev/null +++ b/docs/reference/status.md @@ -0,0 +1,18 @@ + + +# status + +Get the status of a machine. + +``` +$ docker-machine status dev +Running +``` diff --git a/test/integration/core/core-commands.bats b/test/integration/core/core-commands.bats index 70c220ce5e..b79481685b 100644 --- a/test/integration/core/core-commands.bats +++ b/test/integration/core/core-commands.bats @@ -104,3 +104,9 @@ load ${BASE_TEST_DIR}/helpers.bash [ "$status" -eq 0 ] [[ ${lines[1]} == *"Running"* ]] } + +@test "$DRIVER: status" { + run machine status $NAME + [ "$status" -eq 0 ] + [[ ${output} == *"Running"* ]] +}