From cfb25ffb10b7b4024e24a5704d9b793c650c9208 Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Thu, 13 Nov 2014 15:39:51 +0100 Subject: [PATCH] Handle bad options better * Do not log bad options error message twice, e.g.: $ docker run --pouet flag provided but not defined: --pouet See 'docker run --help'. 2014/11/05 21:41:23 flag provided but not defined: --pouet With this patch just the first two lines will be produced. * Print 'docker' just once when run without a command, e.g.: $ docker --hel flag provided but not defined: --hel See 'docker docker --help'. Signed-off-by: Michal Minar --- mflag/flag.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mflag/flag.go b/mflag/flag.go index 42711b7..72addae 100644 --- a/mflag/flag.go +++ b/mflag/flag.go @@ -852,7 +852,11 @@ func Var(value Value, names []string, usage string) { func (f *FlagSet) failf(format string, a ...interface{}) error { err := fmt.Errorf(format, a...) fmt.Fprintln(f.Out(), err) - fmt.Fprintf(f.Out(), "See 'docker %s --help'.\n", f.name) + if os.Args[0] == f.name { + fmt.Fprintf(f.Out(), "See '%s --help'.\n", os.Args[0]) + } else { + fmt.Fprintf(f.Out(), "See '%s %s --help'.\n", os.Args[0], f.name) + } return err }