Browse Source
Write usage message to stderr on error
When the parsing of parameters/flags fails eg. when a required flag is
missing, print the usage statement and error to stderr instead of
stdout.
Fredrik Wallgren
10 years ago
No known key found for this signature in database
GPG Key ID: F47F4EC105BDC53E
1 changed files with
2 additions and
2 deletions
-
usage.go
|
|
|
@ -9,9 +9,9 @@ import ( |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
// Fail prints usage information to stdout and exits with non-zero status
|
|
|
|
// Fail prints usage information to stderr and exits with non-zero status
|
|
|
|
func (p *Parser) Fail(msg string) { |
|
|
|
p.WriteUsage(os.Stdout) |
|
|
|
p.WriteUsage(os.Stderr) |
|
|
|
fmt.Println("error:", msg) |
|
|
|
os.Exit(-1) |
|
|
|
} |
|
|
|
|