diff options
Diffstat (limited to 'err.go')
-rw-r--r-- | err.go | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -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) } |