From 611bd6873951ebb7df4b8d29951dcb4ac5bc340c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 15 Feb 2017 17:45:08 -0800 Subject: [PATCH] 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. --- cmd/main.go | 2 +- cmd/server-main.go | 16 ++++++++-------- cmd/update-main.go | 12 ++++-------- cmd/version-main.go | 13 ++----------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 11e49b005..75b8d531e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -49,7 +49,7 @@ DESCRIPTION: {{.Description}} USAGE: - minio {{if .VisibleFlags}}[flags] {{end}}command{{if .VisibleFlags}}{{end}} [arguments...] + {{.HelpName}} {{if .VisibleFlags}}[FLAGS] {{end}}COMMAND{{if .VisibleFlags}}{{end}} [ARGS...] COMMANDS: {{range .VisibleCommands}}{{join .Names ", "}}{{ "\t" }}{{.Usage}} diff --git a/cmd/server-main.go b/cmd/server-main.go index f48f90d07..b4e063696 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -46,14 +46,14 @@ var serverCmd = cli.Command{ Flags: append(serverFlags, globalFlags...), Action: serverMain, CustomHelpTemplate: `NAME: - minio {{.Name}} - {{.Usage}} + {{.HelpName}} - {{.Usage}} USAGE: - minio {{.Name}} [FLAGS] PATH [PATH...] - + {{.HelpName}} {{if .VisibleFlags}}[FLAGS] {{end}}PATH [PATH...] +{{if .VisibleFlags}} FLAGS: {{range .VisibleFlags}}{{.}} - {{end}} + {{end}}{{end}} ENVIRONMENT VARIABLES: ACCESS: MINIO_ACCESS_KEY: Custom username or access key of 5 to 20 characters in length. @@ -64,20 +64,20 @@ ENVIRONMENT VARIABLES: EXAMPLES: 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. - $ 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. - $ 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/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. $ export MINIO_ACCESS_KEY=minio $ 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/ `, diff --git a/cmd/update-main.go b/cmd/update-main.go index 4876f9849..23721fb2b 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -37,24 +37,20 @@ var updateCmd = cli.Command{ Usage: "Check for a new software update.", Action: mainUpdate, Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "help, h", - Usage: "Show this help.", - }, cli.BoolFlag{ Name: "quiet", Usage: "Disable any update messages.", }, }, CustomHelpTemplate: `Name: - minio {{.Name}} - {{.Usage}} + {{.HelpName}} - {{.Usage}} USAGE: - minio {{.Name}} [FLAGS] - + {{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} +{{if .VisibleFlags}} FLAGS: {{range .VisibleFlags}}{{.}} - {{end}} + {{end}}{{end}} EXIT STATUS: 0 - You are already running the most recent version. 1 - New update is available. diff --git a/cmd/version-main.go b/cmd/version-main.go index 0ca92c52b..f3d547c4f 100644 --- a/cmd/version-main.go +++ b/cmd/version-main.go @@ -25,21 +25,12 @@ var versionCmd = cli.Command{ Name: "version", Usage: "Print version.", Action: mainVersion, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "help, h", - Usage: "Show this help.", - }, - }, CustomHelpTemplate: `NAME: - minio {{.Name}} - {{.Usage}} + {{.HelpName}} - {{.Usage}} USAGE: - minio {{.Name}} + {{.HelpName}} -FLAGS: - {{range .VisibleFlags}}{{.}} - {{end}} VERSION: ` + Version + `{{"\n"}}`, }