update usage to look more like the engine/machine

Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
Victor Vieux 2015-05-15 11:38:35 -07:00
parent 2fd48d8ac4
commit a43f10adc4
2 changed files with 38 additions and 20 deletions

View File

@ -17,7 +17,7 @@ import (
func Run() { func Run() {
app := cli.NewApp() app := cli.NewApp()
app.Name = path.Base(os.Args[0]) app.Name = path.Base(os.Args[0])
app.Usage = "a Docker-native clustering system" app.Usage = "A Docker-native clustering system"
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")" app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
app.Author = "" app.Author = ""
@ -59,7 +59,7 @@ func Run() {
{ {
Name: "create", Name: "create",
ShortName: "c", ShortName: "c",
Usage: "create a cluster", Usage: "Create a cluster",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if len(c.Args()) != 0 { if len(c.Args()) != 0 {
log.Fatalf("the `create` command takes no arguments. See '%s create --help'.", c.App.Name) log.Fatalf("the `create` command takes no arguments. See '%s create --help'.", c.App.Name)
@ -76,7 +76,7 @@ func Run() {
{ {
Name: "list", Name: "list",
ShortName: "l", ShortName: "l",
Usage: "list nodes in a cluster", Usage: "List nodes in a cluster",
Flags: []cli.Flag{flTimeout}, Flags: []cli.Flag{flTimeout},
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
dflag := getDiscovery(c) dflag := getDiscovery(c)
@ -109,7 +109,7 @@ func Run() {
{ {
Name: "manage", Name: "manage",
ShortName: "m", ShortName: "m",
Usage: "manage a docker cluster", Usage: "Manage a docker cluster",
Flags: []cli.Flag{ Flags: []cli.Flag{
flStore, flStore,
flStrategy, flFilter, flStrategy, flFilter,
@ -122,7 +122,7 @@ func Run() {
{ {
Name: "join", Name: "join",
ShortName: "j", ShortName: "j",
Usage: "join a docker cluster", Usage: "Join a docker cluster",
Flags: []cli.Flag{flAddr, flHeartBeat}, Flags: []cli.Flag{flAddr, flHeartBeat},
Action: join, Action: join,
}, },

View File

@ -8,22 +8,40 @@ import (
) )
func init() { func init() {
cli.AppHelpTemplate = `Usage: {{.Name}} {{if .Flags}}[OPTIONS] {{end}}COMMAND [arg...]
{{.Usage}}
Version: {{.Version}}{{if or .Author .Email}}
Author:{{if .Author}}
{{.Author}}{{if .Email}} - <{{.Email}}>{{end}}{{else}}
{{.Email}}{{end}}{{end}}
{{if .Flags}}
Options:
{{range .Flags}}{{.}}
{{end}}{{end}}
Commands:
{{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}}
{{end}}
Run '{{.Name}} COMMAND --help' for more information on a command.
`
// See https://github.com/codegangsta/cli/pull/171/files // See https://github.com/codegangsta/cli/pull/171/files
cli.CommandHelpTemplate = `{{$DISCOVERY := or (eq .Name "manage") (eq .Name "join") (eq .Name "list")}}NAME: cli.CommandHelpTemplate = `{{$DISCOVERY := or (eq .Name "manage") (eq .Name "join") (eq .Name "list")}}Usage: ` + path.Base(os.Args[0]) + ` {{.Name}}{{if .Flags}} [OPTIONS]{{end}} {{if $DISCOVERY}}<discovery>{{end}}
{{.Name}} - {{.Usage}}
USAGE: {{.Usage}}{{if $DISCOVERY}}
` + path.Base(os.Args[0]) + ` {{.Name}}{{if .Flags}} [options]{{end}} {{if $DISCOVERY}}<discovery>{{end}}{{if .Description}}
DESCRIPTION: Arguments:
{{.Description}}{{end}}{{if $DISCOVERY}} <discovery> discovery service to use [$SWARM_DISCOVERY]
ARGUMENTS: * token://<token>
discovery{{printf "\t"}}discovery service to use [$SWARM_DISCOVERY] * consul://<ip>/<path>
{{printf "\t"}} * token://<token> * etcd://<ip1>,<ip2>/<path>
{{printf "\t"}} * consul://<ip>/<path> * file://path/to/file
{{printf "\t"}} * etcd://<ip1>,<ip2>/<path> * zk://<ip1>,<ip2>/<path>
{{printf "\t"}} * file://path/to/file * <ip1>,<ip2>{{end}}{{if .Flags}}
{{printf "\t"}} * zk://<ip1>,<ip2>/<path>
{{printf "\t"}} * <ip1>,<ip2>{{end}}{{if .Flags}} Options:
OPTIONS:
{{range .Flags}}{{.}} {{range .Flags}}{{.}}
{{end}}{{if (eq .Name "manage")}}{{printf "\t * swarm.overcommit=0.05\tovercommit to apply on resources"}} {{end}}{{if (eq .Name "manage")}}{{printf "\t * swarm.overcommit=0.05\tovercommit to apply on resources"}}
{{printf "\t * swarm.discovery.heartbeat=25s\tperiod between each heartbeat"}}{{end}}{{ end }} {{printf "\t * swarm.discovery.heartbeat=25s\tperiod between each heartbeat"}}{{end}}{{ end }}