makes the name optional for stop/start/ssh/upgrade

Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
This commit is contained in:
Simon Thulbourn 2014-12-12 16:23:15 +00:00
parent 64c73597e2
commit 0295e00edb
1 changed files with 43 additions and 17 deletions

View File

@ -42,10 +42,10 @@ func (h HostListItemByName) Less(i, j int) bool {
}
func BeforeHandler(c *cli.Context) error {
if c.Bool("debug") {
os.Setenv("DEBUG", "1")
initLogging(log.DebugLevel)
}
// if c.Bool("debug") {
// os.Setenv("DEBUG", "1")
// initLogging(log.DebugLevel)
// }
return nil
}
@ -119,6 +119,8 @@ var Commands = []cli.Command{
store := NewStore()
fmt.Printf("%#v", c.String("url"))
host, err := store.Create(name, driver, c)
if err != nil {
log.Errorf("%s", err)
@ -351,10 +353,16 @@ var Commands = []cli.Command{
Usage: "Log into or run a command on a machine with SSH",
Action: func(c *cli.Context) {
name := c.Args().First()
store := NewStore()
if name == "" {
cli.ShowCommandHelp(c, "ssh")
os.Exit(1)
host, err := store.GetActive()
if err != nil {
log.Errorf("error unable to get active host")
os.Exit(1)
}
name = host.Name
}
i := 1
@ -362,8 +370,6 @@ var Commands = []cli.Command{
i++
}
store := NewStore()
host, err := store.Load(name)
if err != nil {
log.Errorf("%s", err)
@ -390,9 +396,18 @@ var Commands = []cli.Command{
Usage: "Start a machine",
Action: func(c *cli.Context) {
name := c.Args().First()
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")
@ -407,13 +422,18 @@ var Commands = []cli.Command{
Usage: "Stop a machine",
Action: func(c *cli.Context) {
name := c.Args().First()
if name == "" {
cli.ShowCommandHelp(c, "stop")
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")
@ -428,12 +448,18 @@ var Commands = []cli.Command{
Usage: "Upgrade a machine to the latest version of Docker",
Action: func(c *cli.Context) {
name := c.Args().First()
store := NewStore()
if name == "" {
cli.ShowCommandHelp(c, "upgrade")
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 unable to load host")