diff --git a/commands/commands.go b/commands/commands.go index 9f85f051..e0d0079e 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -379,6 +379,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 00000000..d775bba8 --- /dev/null +++ b/commands/status.go @@ -0,0 +1,18 @@ +package commands + +import ( + "fmt" + + "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) + } + fmt.Println(currentState) +} diff --git a/commands/status_test.go b/commands/status_test.go new file mode 100644 index 00000000..cdff10da --- /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 fa451586..3976e2a8 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 00000000..815800c9 --- /dev/null +++ b/docs/reference/status.md @@ -0,0 +1,18 @@ + + +# status + +Get the status of a machine. + +``` +$ docker-machine status dev +Running +```