diff options
author | Thomas Voss <mail@thomasvoss.com> | 2021-10-08 23:46:05 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2021-10-08 23:46:05 +0200 |
commit | d4a272edf46ad64b5bb9f1d1305f471d1f15ecfa (patch) | |
tree | 8fe297cbb9091eecac286833a375bfcd88850b5d /tests/tests.go |
[Meta] Initial commit
Diffstat (limited to 'tests/tests.go')
-rw-r--r-- | tests/tests.go | 23 |
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) + } + } +} |