Improve handling of cmdline errors (#91)

Improve handling of cmdline errors
This commit is contained in:
Yann Hamon 2022-01-06 12:39:24 +01:00 committed by GitHub
parent 607c90a0a9
commit 85b30f8c2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -4,7 +4,6 @@ import (
"bytes"
"flag"
"fmt"
"os"
"strings"
)
@ -82,9 +81,7 @@ func FromFlags(progName string, args []string) (Config, string, error) {
flags.BoolVar(&c.Help, "h", false, "show help information")
flags.BoolVar(&c.Version, "v", false, "show version information")
flags.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]... [FILE OR FOLDER]...\n", progName)
flags.SetOutput(os.Stderr)
fmt.Fprintf(&buf, "Usage: %s [OPTION]... [FILE OR FOLDER]...\n", progName)
flags.PrintDefaults()
}