aboutsummaryrefslogtreecommitdiff
path: root/err.go
diff options
context:
space:
mode:
Diffstat (limited to 'err.go')
-rw-r--r--err.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/err.go b/err.go
index cbe96b4..23692fa 100644
--- a/err.go
+++ b/err.go
@@ -4,16 +4,28 @@ import "fmt"
// A BadOptionError describes an option that the user attempted to pass
// which the developer did not register.
-type BadOptionError rune
+type BadOptionError struct {
+ r rune
+ s string
+}
func (e BadOptionError) Error() string {
- return fmt.Sprintf("unknown option ‘%c’", e)
+ if e.r != 0 {
+ return fmt.Sprintf("unknown option ‘-%c’", e.r)
+ }
+ return fmt.Sprintf("unknown option ‘--%s’", e.s)
}
// A NoArgumentError describes an option that the user attempted to pass
// without an argument, which required an argument.
-type NoArgumentError rune
+type NoArgumentError struct {
+ r rune
+ s string
+}
func (e NoArgumentError) Error() string {
- return fmt.Sprintf("expected argument for option ‘%c’", e)
+ if e.r != 0 {
+ return fmt.Sprintf("expected argument for option ‘-%c’", e.r)
+ }
+ return fmt.Sprintf("expected argument for option ‘--%s’", e.s)
}