mirror of https://github.com/docker/docs.git
Make machine name optional in CLI
For commands inspect, ip, kill and restart. It is already implemented for the others. Signed-off-by: Guillaume Giamarchi <guillaume.giamarchi@gmail.com>
This commit is contained in:
parent
477fffb1ba
commit
8613b941e8
43
commands.go
43
commands.go
|
|
@ -129,13 +129,18 @@ var Commands = []cli.Command{
|
|||
Usage: "Inspect information about a machine",
|
||||
Action: func(c *cli.Context) {
|
||||
name := c.Args().First()
|
||||
store := NewStore()
|
||||
|
||||
if name == "" {
|
||||
cli.ShowCommandHelp(c, "inspect")
|
||||
os.Exit(1)
|
||||
host, err := store.GetActive()
|
||||
if err != nil {
|
||||
log.Errorf("error unable to get active host")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
name = host.Name
|
||||
}
|
||||
|
||||
store := NewStore()
|
||||
host, err := store.Load(name)
|
||||
if err != nil {
|
||||
log.Errorf("error loading data")
|
||||
|
|
@ -157,11 +162,6 @@ var Commands = []cli.Command{
|
|||
Action: func(c *cli.Context) {
|
||||
name := c.Args().First()
|
||||
|
||||
if name == "" {
|
||||
cli.ShowCommandHelp(c, "ip")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var (
|
||||
err error
|
||||
host *Host
|
||||
|
|
@ -199,13 +199,17 @@ var Commands = []cli.Command{
|
|||
Usage: "Kill a machine",
|
||||
Action: func(c *cli.Context) {
|
||||
name := c.Args().First()
|
||||
store := NewStore()
|
||||
|
||||
if name == "" {
|
||||
cli.ShowCommandHelp(c, "kill")
|
||||
os.Exit(1)
|
||||
}
|
||||
host, err := store.GetActive()
|
||||
if err != nil {
|
||||
log.Errorf("error unable to get active host")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
store := NewStore()
|
||||
name = host.Name
|
||||
}
|
||||
|
||||
host, err := store.Load(name)
|
||||
if err != nil {
|
||||
|
|
@ -291,13 +295,18 @@ var Commands = []cli.Command{
|
|||
Usage: "Restart a machine",
|
||||
Action: func(c *cli.Context) {
|
||||
name := c.Args().First()
|
||||
if name == "" {
|
||||
cli.ShowCommandHelp(c, "restart")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
store := NewStore()
|
||||
|
||||
if name == "" {
|
||||
host, err := store.GetActive()
|
||||
if err != nil {
|
||||
log.Errorf("error unable to get active host")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
name = host.Name
|
||||
}
|
||||
|
||||
host, err := store.Load(name)
|
||||
if err != nil {
|
||||
log.Errorf("error unable to load data")
|
||||
|
|
|
|||
Loading…
Reference in New Issue