diff --git a/help.go b/help.go index 6361279313..995fe6ca74 100644 --- a/help.go +++ b/help.go @@ -1,13 +1,18 @@ package main -import "github.com/codegangsta/cli" +import ( + "os" + "path" + + "github.com/codegangsta/cli" +) func init() { - + // See https://github.com/codegangsta/cli/pull/171/files cli.CommandHelpTemplate = `{{$DISCOVERY := or (eq .Name "manage") (eq .Name "join") (eq .Name "list")}}NAME: {{.Name}} - {{.Usage}} USAGE: - swarm {{.Name}}{{if .Flags}} [options]{{end}} {{if $DISCOVERY}}{{end}}{{if .Description}} + ` + path.Base(os.Args[0]) + ` {{.Name}}{{if .Flags}} [options]{{end}} {{if $DISCOVERY}}{{end}}{{if .Description}} DESCRIPTION: {{.Description}}{{end}}{{if $DISCOVERY}} ARGUMENTS: diff --git a/join.go b/join.go index 5ff52ca423..26ba65e866 100644 --- a/join.go +++ b/join.go @@ -17,7 +17,7 @@ func checkAddrFormat(addr string) bool { func join(c *cli.Context) { dflag := getDiscovery(c) if dflag == "" { - log.Fatal("discovery required to join a cluster. See 'swarm join --help'.") + log.Fatalf("discovery required to join a cluster. See '%s join --help'.", c.App.Name) } d, err := discovery.New(dflag, c.Int("heartbeat")) diff --git a/main.go b/main.go index 56b4775cb6..ad29fa1b63 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "path" log "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" @@ -18,7 +19,7 @@ import ( func main() { app := cli.NewApp() - app.Name = "swarm" + app.Name = path.Base(os.Args[0]) app.Usage = "a Docker-native clustering system" app.Version = "0.1.0" app.Author = "" @@ -78,7 +79,7 @@ func main() { Action: func(c *cli.Context) { dflag := getDiscovery(c) if dflag == "" { - log.Fatal("discovery required to list a cluster. See 'swarm list --help'.") + log.Fatalf("discovery required to list a cluster. See '%s list --help'.", c.App.Name) } d, err := discovery.New(dflag, 0) diff --git a/manage.go b/manage.go index b478308fc2..21c44a4e56 100644 --- a/manage.go +++ b/manage.go @@ -83,7 +83,7 @@ func manage(c *cli.Context) { dflag := getDiscovery(c) if dflag == "" { - log.Fatal("discovery required to manage a cluster. See 'swarm manage --help'.") + log.Fatalf("discovery required to manage a cluster. See '%s manage --help'.", c.App.Name) } s, err := strategy.New(c.String("strategy"))