Add status command

closes #1471 by adding the status command that prints the state of a
machine.

Signed-off-by: Sergio Botero <sergiobuj@gmail.com>
This commit is contained in:
Sergio Botero
2015-07-10 21:07:40 -06:00
parent e054d06163
commit 87cf7e222e
5 changed files with 45 additions and 1 deletions

View File

@@ -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",

18
commands/status.go Normal file
View File

@@ -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)
}

1
commands/status_test.go Normal file
View File

@@ -0,0 +1 @@
package commands

View File

@@ -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)
* [url](url.md)

18
docs/reference/status.md Normal file
View File

@@ -0,0 +1,18 @@
<!--[metadata]>
+++
title = "status"
description = "Get the status of a machine"
keywords = ["machine, status, subcommand"]
[menu.main]
parent="smn_machine_subcmds"
+++
<![end-metadata]-->
# status
Get the status of a machine.
```
$ docker-machine status dev
Running
```