From 976d3852fd98a8db053b34e223e783bde5c75406 Mon Sep 17 00:00:00 2001 From: ehlxr Date: Fri, 15 Nov 2019 10:16:19 +0800 Subject: [PATCH] init --- main.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 5083276..64be1ad 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func initLog() { } func parseArg() { - parser := flags.NewParser(&opts, flags.Default) + parser := flags.NewParser(&opts, flags.HelpFlag|flags.PassDoubleDash) if _, err := parser.Parse(); err != nil { if opts.Version { printVersion() @@ -102,13 +102,16 @@ func parseArg() { } if flagsErr, ok := err.(*flags.Error); ok && flagsErr.Type == flags.ErrHelp { + _, _ = fmt.Fprintln(os.Stdout, err) os.Exit(0) - } else { - parser.Name = AppName - parser.WriteHelp(os.Stderr) - - os.Exit(1) } + + _, _ = fmt.Fprintln(os.Stderr, err) + + parser.Name = AppName + parser.WriteHelp(os.Stderr) + + os.Exit(1) } }