cli: Add new features from CLI.

use `.HelpName` for template to pass down
proper command names. Also treat flags
to be optional in all of them.
This commit is contained in:
Harshavardhana 2017-02-15 17:45:08 -08:00
parent 25eeb88a8f
commit 611bd68739
4 changed files with 15 additions and 28 deletions

View file

@ -49,7 +49,7 @@ DESCRIPTION:
{{.Description}} {{.Description}}
USAGE: USAGE:
minio {{if .VisibleFlags}}[flags] {{end}}command{{if .VisibleFlags}}{{end}} [arguments...] {{.HelpName}} {{if .VisibleFlags}}[FLAGS] {{end}}COMMAND{{if .VisibleFlags}}{{end}} [ARGS...]
COMMANDS: COMMANDS:
{{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} {{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}}

View file

@ -46,14 +46,14 @@ var serverCmd = cli.Command{
Flags: append(serverFlags, globalFlags...), Flags: append(serverFlags, globalFlags...),
Action: serverMain, Action: serverMain,
CustomHelpTemplate: `NAME: CustomHelpTemplate: `NAME:
minio {{.Name}} - {{.Usage}} {{.HelpName}} - {{.Usage}}
USAGE: USAGE:
minio {{.Name}} [FLAGS] PATH [PATH...] {{.HelpName}} {{if .VisibleFlags}}[FLAGS] {{end}}PATH [PATH...]
{{if .VisibleFlags}}
FLAGS: FLAGS:
{{range .VisibleFlags}}{{.}} {{range .VisibleFlags}}{{.}}
{{end}} {{end}}{{end}}
ENVIRONMENT VARIABLES: ENVIRONMENT VARIABLES:
ACCESS: ACCESS:
MINIO_ACCESS_KEY: Custom username or access key of 5 to 20 characters in length. MINIO_ACCESS_KEY: Custom username or access key of 5 to 20 characters in length.
@ -64,20 +64,20 @@ ENVIRONMENT VARIABLES:
EXAMPLES: EXAMPLES:
1. Start minio server on "/home/shared" directory. 1. Start minio server on "/home/shared" directory.
$ minio {{.Name}} /home/shared $ {{.HelpName}} /home/shared
2. Start minio server bound to a specific IP:PORT. 2. Start minio server bound to a specific IP:PORT.
$ minio {{.Name}} --address 192.168.1.101:9000 /home/shared $ {{.HelpName}} --address 192.168.1.101:9000 /home/shared
3. Start erasure coded minio server on a 12 disks server. 3. Start erasure coded minio server on a 12 disks server.
$ minio {{.Name}} /mnt/export1/ /mnt/export2/ /mnt/export3/ /mnt/export4/ \ $ {{.HelpName}} /mnt/export1/ /mnt/export2/ /mnt/export3/ /mnt/export4/ \
/mnt/export5/ /mnt/export6/ /mnt/export7/ /mnt/export8/ /mnt/export9/ \ /mnt/export5/ /mnt/export6/ /mnt/export7/ /mnt/export8/ /mnt/export9/ \
/mnt/export10/ /mnt/export11/ /mnt/export12/ /mnt/export10/ /mnt/export11/ /mnt/export12/
4. Start erasure coded distributed minio server on a 4 node setup with 1 drive each. Run following commands on all the 4 nodes. 4. Start erasure coded distributed minio server on a 4 node setup with 1 drive each. Run following commands on all the 4 nodes.
$ export MINIO_ACCESS_KEY=minio $ export MINIO_ACCESS_KEY=minio
$ export MINIO_SECRET_KEY=miniostorage $ export MINIO_SECRET_KEY=miniostorage
$ minio {{.Name}} http://192.168.1.11/mnt/export/ http://192.168.1.12/mnt/export/ \ $ {{.HelpName}} http://192.168.1.11/mnt/export/ http://192.168.1.12/mnt/export/ \
http://192.168.1.13/mnt/export/ http://192.168.1.14/mnt/export/ http://192.168.1.13/mnt/export/ http://192.168.1.14/mnt/export/
`, `,

View file

@ -37,24 +37,20 @@ var updateCmd = cli.Command{
Usage: "Check for a new software update.", Usage: "Check for a new software update.",
Action: mainUpdate, Action: mainUpdate,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Show this help.",
},
cli.BoolFlag{ cli.BoolFlag{
Name: "quiet", Name: "quiet",
Usage: "Disable any update messages.", Usage: "Disable any update messages.",
}, },
}, },
CustomHelpTemplate: `Name: CustomHelpTemplate: `Name:
minio {{.Name}} - {{.Usage}} {{.HelpName}} - {{.Usage}}
USAGE: USAGE:
minio {{.Name}} [FLAGS] {{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}}
{{if .VisibleFlags}}
FLAGS: FLAGS:
{{range .VisibleFlags}}{{.}} {{range .VisibleFlags}}{{.}}
{{end}} {{end}}{{end}}
EXIT STATUS: EXIT STATUS:
0 - You are already running the most recent version. 0 - You are already running the most recent version.
1 - New update is available. 1 - New update is available.

View file

@ -25,21 +25,12 @@ var versionCmd = cli.Command{
Name: "version", Name: "version",
Usage: "Print version.", Usage: "Print version.",
Action: mainVersion, Action: mainVersion,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Show this help.",
},
},
CustomHelpTemplate: `NAME: CustomHelpTemplate: `NAME:
minio {{.Name}} - {{.Usage}} {{.HelpName}} - {{.Usage}}
USAGE: USAGE:
minio {{.Name}} {{.HelpName}}
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
VERSION: VERSION:
` + Version + `{{"\n"}}`, ` + Version + `{{"\n"}}`,
} }