From f94989dc0a2e574773d4a332762c28af8c8c1991 Mon Sep 17 00:00:00 2001 From: "Anand Babu (AB) Periasamy" Date: Wed, 25 Nov 2015 15:08:16 -0800 Subject: [PATCH] support global flags for both commands and global main Change-Id: If0939b52ad3ccb8d5ada0118515c2ad398bceef0 --- main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.go b/main.go index 975fa77a..216b498f 100644 --- a/main.go +++ b/main.go @@ -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