support global flags for both commands and global main

Change-Id: If0939b52ad3ccb8d5ada0118515c2ad398bceef0
This commit is contained in:
Anand Babu (AB) Periasamy
2015-11-25 15:08:16 -08:00
parent 9fe3b00394
commit f94989dc0a
+13
View File
@@ -29,6 +29,15 @@ import (
"github.com/olekukonko/ts"
)
var (
mcFlags = []cli.Flag{
cli.BoolFlag{
Name: "help, h",
Usage: "Show help.",
},
}
)
// Help template for mc
var mcHelpTemplate = `NAME:
{{.Name}} - {{.Usage}}
@@ -116,6 +125,9 @@ func registerBefore(ctx *cli.Context) error {
// Migrate any old version of config / state files to newer format.
migrate()
// Set global flags.
setGlobalsFromContext(ctx)
// Checkconfig if it can be read.
checkConfig()
@@ -153,6 +165,7 @@ func registerApp() *cli.App {
app.Usage = "Minio Client for cloud storage and filesystems."
app.Commands = commands
app.Author = "Minio.io"
app.Flags = append(mcFlags, globalFlags...)
app.CustomAppHelpTemplate = mcHelpTemplate
app.CommandNotFound = commandNotFound // handler function declared above.
return app