From fdbd555f75b7719a2500eea8a4b510e8f4b40945 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Wed, 5 Mar 2014 19:27:39 +0000 Subject: [PATCH] fix usage for completly deprecated flag Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) Upstream-commit: 089bf5e11e4284a6ed07dc165098bb269dfddf46 Component: engine --- components/engine/pkg/mflag/example/example.go | 1 + components/engine/pkg/mflag/flag.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/engine/pkg/mflag/example/example.go b/components/engine/pkg/mflag/example/example.go index b0d25fbfc6..352f652ebe 100644 --- a/components/engine/pkg/mflag/example/example.go +++ b/components/engine/pkg/mflag/example/example.go @@ -12,6 +12,7 @@ var ( ) func init() { + flag.Bool([]string{"#hp", "#-halp"}, false, "display the halp") flag.BoolVar(&b, []string{"b"}, false, "a simple bool") flag.BoolVar(&b2, []string{"-bool"}, false, "a simple bool") flag.IntVar(&i, []string{"#integer", "-integer"}, -1, "a simple integer") diff --git a/components/engine/pkg/mflag/flag.go b/components/engine/pkg/mflag/flag.go index 6fe3e41b23..ff0de23f78 100644 --- a/components/engine/pkg/mflag/flag.go +++ b/components/engine/pkg/mflag/flag.go @@ -404,7 +404,9 @@ func (f *FlagSet) PrintDefaults() { names = append(names, name) } } - fmt.Fprintf(f.out(), format, strings.Join(names, ", -"), flag.DefValue, flag.Usage) + if len(names) > 0 { + fmt.Fprintf(f.out(), format, strings.Join(names, ", -"), flag.DefValue, flag.Usage) + } }) }