diff --git a/cmd/commands.go b/cmd/commands.go index f40e56553..96aa05ec0 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -24,19 +24,6 @@ var commands = []cli.Command{} // Collection of minio commands currently supported in a trie tree. var commandsTree = newTrie() -// Collection of minio flags currently supported. -var globalFlags = []cli.Flag{ - cli.StringFlag{ - Name: "config-dir, C", - Value: mustGetConfigPath(), - Usage: "Path to configuration folder.", - }, - cli.BoolFlag{ - Name: "quiet", - Usage: "Suppress chatty output.", - }, -} - // registerCommand registers a cli command. func registerCommand(command cli.Command) { commands = append(commands, command) diff --git a/cmd/control-heal-main.go b/cmd/control-heal-main.go index 2b8a15c70..96d8c8035 100644 --- a/cmd/control-heal-main.go +++ b/cmd/control-heal-main.go @@ -29,12 +29,17 @@ var healCmd = cli.Command{ Name: "heal", Usage: "To heal objects.", Action: healControl, + Flags: globalFlags, CustomHelpTemplate: `NAME: minio control {{.Name}} - {{.Usage}} USAGE: minio control {{.Name}} +FLAGS: + {{range .Flags}}{{.}} + {{end}} + EXAMPLES: 1. Heal an object. $ minio control {{.Name}} http://localhost:9000/songs/classical/western/piano.mp3 diff --git a/cmd/control-lock-main.go b/cmd/control-lock-main.go index 9cd5757e4..620412cb8 100644 --- a/cmd/control-lock-main.go +++ b/cmd/control-lock-main.go @@ -97,12 +97,17 @@ var lockCmd = cli.Command{ Name: "lock", Usage: "info about the locks in the node.", Action: lockControl, + Flags: globalFlags, CustomHelpTemplate: `NAME: minio control {{.Name}} - {{.Usage}} USAGE: minio control {{.Name}} http://localhost:9000/ +FLAGS: + {{range .Flags}}{{.}} + {{end}} + EAMPLES: 1. Get all the info about the blocked/held locks in the node: $ minio control lock http://localhost:9000/ diff --git a/cmd/control-main.go b/cmd/control-main.go index aa9c17123..d0eb917e5 100644 --- a/cmd/control-main.go +++ b/cmd/control-main.go @@ -22,6 +22,7 @@ import "github.com/minio/cli" var controlCmd = cli.Command{ Name: "control", Usage: "Control and manage minio server.", + Flags: globalFlags, Action: mainControl, Subcommands: []cli.Command{ lockCmd, diff --git a/cmd/control-shutdown-main.go b/cmd/control-shutdown-main.go index a9198b4da..28b6d9457 100644 --- a/cmd/control-shutdown-main.go +++ b/cmd/control-shutdown-main.go @@ -23,22 +23,28 @@ import ( "github.com/minio/cli" ) +var shutdownFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "restart", + Usage: "Restart the server.", + }, +} + var shutdownCmd = cli.Command{ Name: "shutdown", Usage: "Shutdown or restart the server.", Action: shutdownControl, - Flags: []cli.Flag{ - cli.BoolFlag{ - Name: "restart", - Usage: "Restart the server.", - }, - }, + Flags: append(shutdownFlags, globalFlags...), CustomHelpTemplate: `NAME: minio control {{.Name}} - {{.Usage}} USAGE: minio control {{.Name}} http://localhost:9000/ +FLAGS: + {{range .Flags}}{{.}} + {{end}} + EXAMPLES: 1. Shutdown the server: $ minio control shutdown http://localhost:9000/ diff --git a/cmd/main.go b/cmd/main.go index 00e8157be..ddb4a1f4d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -27,11 +27,20 @@ import ( var ( // global flags for minio. - minioFlags = []cli.Flag{ + globalFlags = []cli.Flag{ cli.BoolFlag{ Name: "help, h", Usage: "Show help.", }, + cli.StringFlag{ + Name: "config-dir, C", + Value: mustGetConfigPath(), + Usage: "Path to configuration folder.", + }, + cli.BoolFlag{ + Name: "quiet", + Usage: "Suppress chatty output.", + }, } ) @@ -115,7 +124,7 @@ func registerApp() *cli.App { app.Author = "Minio.io" app.Usage = "Cloud Storage Server." app.Description = `Minio is an Amazon S3 compatible object storage server. Use it to store photos, videos, VMs, containers, log files, or any blob of data as objects.` - app.Flags = append(minioFlags, globalFlags...) + app.Flags = globalFlags app.Commands = commands app.CustomAppHelpTemplate = minioHelpTemplate app.CommandNotFound = func(ctx *cli.Context, command string) { diff --git a/cmd/server-main.go b/cmd/server-main.go index 3dd1cd81c..663a538fb 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -29,20 +29,23 @@ import ( ) var srvConfig serverCmdConfig -var serverCmd = cli.Command{ - Name: "server", - Usage: "Start object storage server.", - Flags: []cli.Flag{ - cli.StringFlag{ - Name: "address", - Value: ":9000", - Usage: "Specify custom server \"ADDRESS:PORT\", defaults to \":9000\".", - }, - cli.StringFlag{ - Name: "ignore-disks", - Usage: "Specify comma separated list of disks that are offline.", - }, + +var serverFlags = []cli.Flag{ + cli.StringFlag{ + Name: "address", + Value: ":9000", + Usage: "Specify custom server \"ADDRESS:PORT\", defaults to \":9000\".", + }, + cli.StringFlag{ + Name: "ignore-disks", + Usage: "Specify comma separated list of disks that are offline.", }, +} + +var serverCmd = cli.Command{ + Name: "server", + Usage: "Start object storage server.", + Flags: append(serverFlags, globalFlags...), Action: serverMain, CustomHelpTemplate: `NAME: minio {{.Name}} - {{.Usage}} diff --git a/cmd/update-main.go b/cmd/update-main.go index a6a8885fc..18bf966bc 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -33,10 +33,6 @@ import ( // command specific flags. var ( updateFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "help, h", - Usage: "Help for update.", - }, cli.BoolFlag{ Name: "experimental, E", Usage: "Check experimental update.", @@ -49,7 +45,7 @@ var updateCmd = cli.Command{ Name: "update", Usage: "Check for a new software update.", Action: mainUpdate, - Flags: updateFlags, + Flags: append(updateFlags, globalFlags...), CustomHelpTemplate: `Name: minio {{.Name}} - {{.Usage}} diff --git a/cmd/version-main.go b/cmd/version-main.go index 8b0bb8d03..1d621a8fd 100644 --- a/cmd/version-main.go +++ b/cmd/version-main.go @@ -25,15 +25,25 @@ var versionCmd = cli.Command{ Name: "version", Usage: "Print version.", Action: mainVersion, + Flags: globalFlags, CustomHelpTemplate: `NAME: minio {{.Name}} - {{.Usage}} USAGE: - minio {{.Name}} {{if .Description}} + minio {{.Name}} + +FLAGS: + {{range .Flags}}{{.}} + {{end}} + `, } func mainVersion(ctx *cli.Context) { + if len(ctx.Args()) != 0 { + cli.ShowCommandHelpAndExit(ctx, "version", 1) + } + console.Println("Version: " + Version) console.Println("Release-Tag: " + ReleaseTag) console.Println("Commit-ID: " + CommitID)