aboutsummaryrefslogtreecommitdiff
path: root/v2/err.go
diff options
context:
space:
mode:
Diffstat (limited to 'v2/err.go')
-rw-r--r--v2/err.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/v2/err.go b/v2/err.go
new file mode 100644
index 0000000..23692fa
--- /dev/null
+++ b/v2/err.go
@@ -0,0 +1,31 @@
+package opts
+
+import "fmt"
+
+// A BadOptionError describes an option that the user attempted to pass
+// which the developer did not register.
+type BadOptionError struct {
+ r rune
+ s string
+}
+
+func (e BadOptionError) Error() string {
+ 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 struct {
+ r rune
+ s string
+}
+
+func (e NoArgumentError) Error() string {
+ if e.r != 0 {
+ return fmt.Sprintf("expected argument for option ‘-%c’", e.r)
+ }
+ return fmt.Sprintf("expected argument for option ‘--%s’", e.s)
+}