aboutsummaryrefslogtreecommitdiff
path: root/tests/tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tests.go')
-rw-r--r--tests/tests.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/tests.go b/tests/tests.go
new file mode 100644
index 0000000..47aef19
--- /dev/null
+++ b/tests/tests.go
@@ -0,0 +1,23 @@
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/Mango0x45/getgopt"
+)
+
+func main() {
+ for opt := byte(0); getgopt.Getopt(len(os.Args), os.Args, ":a:x", &opt); {
+ switch opt {
+ case 'a':
+ fmt.Printf("Valid flag 'a' with arg '%s'\n", getgopt.Optarg)
+ case 'x':
+ fmt.Println("Valid flag 'x'")
+ case ':':
+ fmt.Printf("Valid flag '%c' with no arg\n", getgopt.Optopt)
+ case '?':
+ fmt.Printf("Invalid flag '%c'\n", getgopt.Optopt)
+ }
+ }
+}