1
0
mirror of https://github.com/docker/docs.git synced 2026-10-31 10:34:26 +03:00

Merge pull request #282 from radeksimko/variable-app-name

Use actual binary name instead of hardcoding it
This commit is contained in:
Victor Vieux
2015-01-24 10:57:43 -08:00
4 changed files with 13 additions and 7 deletions

11
help.go
View File

@@ -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}}<discovery>{{end}}{{if .Description}}
` + path.Base(os.Args[0]) + ` {{.Name}}{{if .Flags}} [options]{{end}} {{if $DISCOVERY}}<discovery>{{end}}{{if .Description}}
DESCRIPTION:
{{.Description}}{{end}}{{if $DISCOVERY}}
ARGUMENTS:

View File

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

View File

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

View File

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