aboutsummaryrefslogtreecommitdiff
path: root/v2/err.go
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-12-05 01:32:52 +0100
committerThomas Voss <mail@thomasvoss.com> 2023-12-05 01:32:52 +0100
commit264780bb60dda33e8d06c48be5f1991212d62a9a (patch)
tree684d61e3e7aaddf73ce4e7c6fc731f72a23a7fac /v2/err.go
parent799bb3be1d099ce6979cd6baa8b84acc507130bd (diff)
Replace ‘optind’ with ‘rest’ in Get() and GetLong() returnsHEADv2.0.0master
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)
+}