summaryrefslogtreecommitdiff
path: root/usage.go
diff options
context:
space:
mode:
authorHugo Hromic <[email protected]>2024-06-29 15:42:05 +0100
committerHugo Hromic <[email protected]>2024-06-29 15:44:50 +0100
commita7c40c36a3a425dd1d28cbc97a3340aafb494d19 (patch)
treee6277a9c3ab651484c233da699fa90874fcdf3ee /usage.go
parentbee5cf5d7cc07c41b2a528052bfba0566b5069c0 (diff)
Use standard exit status code for usage errors
* The stdlib `flags` package and most command line utilities use status code `2`.
Diffstat (limited to 'usage.go')
-rw-r--r--usage.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/usage.go b/usage.go
index 6b578a5..f5e4b38 100644
--- a/usage.go
+++ b/usage.go
@@ -9,13 +9,13 @@ import (
// the width of the left column
const colWidth = 25
-// Fail prints usage information to stderr and exits with non-zero status
+// Fail prints usage information to p.Config.Out and exits with status code 2.
func (p *Parser) Fail(msg string) {
p.FailSubcommand(msg)
}
-// FailSubcommand prints usage information for a specified subcommand to stderr,
-// then exits with non-zero status. To write usage information for a top-level
+// FailSubcommand prints usage information for a specified subcommand to p.Config.Out,
+// then exits with status code 2. To write usage information for a top-level
// subcommand, provide just the name of that subcommand. To write usage
// information for a subcommand that is nested under another subcommand, provide
// a sequence of subcommand names starting with the top-level subcommand and so
@@ -27,7 +27,7 @@ func (p *Parser) FailSubcommand(msg string, subcommand ...string) error {
}
fmt.Fprintln(p.config.Out, "error:", msg)
- p.config.Exit(-1)
+ p.config.Exit(2)
return nil
}