From d4a272edf46ad64b5bb9f1d1305f471d1f15ecfa Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 8 Oct 2021 23:46:05 +0200 Subject: [Meta] Initial commit --- tests/tests.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/tests.go (limited to 'tests/tests.go') 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) + } + } +} -- cgit v1.2.3