diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 460ba21e..b52600fa 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -19,8 +19,8 @@ }, { "ImportPath": "github.com/minio/cli", - "Comment": "1.2.0-112-g823349c", - "Rev": "823349ce91e76834a4af0119d5bbc58fd4d2c6b0" + "Comment": "1.2.0-114-g9280cba", + "Rev": "9280cbaadcdd26d50b5ae85123682e37944701de" }, { "ImportPath": "github.com/minio/minio-go", diff --git a/Godeps/_workspace/src/github.com/minio/cli/app.go b/Godeps/_workspace/src/github.com/minio/cli/app.go index acde02bb..de006dbe 100644 --- a/Godeps/_workspace/src/github.com/minio/cli/app.go +++ b/Godeps/_workspace/src/github.com/minio/cli/app.go @@ -46,7 +46,7 @@ type App struct { // Compilation date Compiled string // ExtraInfo pass additional info as a key value map - ExtraInfo map[string]string + ExtraInfo func() map[string]string // List of all authors who contributed Authors []Author // Name of Author (Note: Use App.Authors, this is deprecated) @@ -125,10 +125,13 @@ func (a *App) Run(arguments []string) (err error) { }() HelpPrinter = func(templ string, data interface{}) { - funcMap := template.FuncMap{ - "join": strings.Join, + funcMap := template.FuncMap{} + funcMap["join"] = strings.Join + // if ExtraInfo function + funcMap["ExtraInfo"] = func() map[string]string { return make(map[string]string) } + if a.ExtraInfo != nil { + funcMap["ExtraInfo"] = a.ExtraInfo } - w := tabwriter.NewWriter(a.Writer, 0, 8, 1, '\t', 0) t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) err := t.Execute(w, data) diff --git a/Godeps/_workspace/src/github.com/minio/cli/help.go b/Godeps/_workspace/src/github.com/minio/cli/help.go index cb36641c..683553d6 100644 --- a/Godeps/_workspace/src/github.com/minio/cli/help.go +++ b/Godeps/_workspace/src/github.com/minio/cli/help.go @@ -25,7 +25,7 @@ VERSION: {{if .Compiled}} BUILD: {{.Compiled}}{{end}} -{{range $key, $value := .ExtraInfo}} +{{range $key, $value := ExtraInfo}} {{$value}}{{end}} ` diff --git a/main.go b/main.go index 25e6a815..88d9eb28 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,13 @@ func checkConfig() { } +func migrate() { + // Migrate config files if any. + migrateConfig() + // Migrate session files if any. + migrateSession() +} + // Get os/arch/platform specific information. // Returns a map of current os/arch/platform/memstats func getSystemData() map[string]string { @@ -63,7 +70,7 @@ func getSystemData() map[string]string { } memstats := &runtime.MemStats{} runtime.ReadMemStats(memstats) - mem := fmt.Sprintf("Used: %s | Allocated: %s | Used-Heap: %s | Allocated-Heap: %s", + mem := fmt.Sprintf("Used: %s | Allocated: %s | UsedHeap: %s | AllocatedHeap: %s", pb.FormatBytes(int64(memstats.Alloc)), pb.FormatBytes(int64(memstats.TotalAlloc)), pb.FormatBytes(int64(memstats.HeapAlloc)), @@ -78,13 +85,6 @@ func getSystemData() map[string]string { } } -func migrate() { - // Migrate config files if any. - migrateConfig() - // Migrate session files if any. - migrateSession() -} - func registerBefore(ctx *cli.Context) error { if ctx.GlobalString("config") != "" { setMcConfigDir(ctx.GlobalString("config")) @@ -96,6 +96,9 @@ func registerBefore(ctx *cli.Context) error { globalDebugFlag = ctx.GlobalBool("debug") globalJSONFlag = ctx.GlobalBool("json") themeName := ctx.GlobalString("theme") + if globalDebugFlag { + console.NoDebugPrint = false + } switch { case console.IsValidTheme(themeName) != true: console.Errorf("Invalid theme, please choose from the following list: %s.\n", console.GetThemeNames()) @@ -162,7 +165,7 @@ GLOBAL FLAGS: VERSION: {{if .Compiled}} {{.Compiled}}{{end}} - {{range $key, $value := .ExtraInfo}} + {{range $key, $value := ExtraInfo}} {{$key}}: {{$value}} {{end}} @@ -183,10 +186,11 @@ func main() { app := registerApp() app.Before = registerBefore app.After = registerAfter - if globalDebugFlag { - app.ExtraInfo = getSystemData() - console.NoDebugPrint = false + app.ExtraInfo = func() map[string]string { + if globalDebugFlag { + return getSystemData() + } + return make(map[string]string) } - app.RunAndExitOnError() }