blob: bbcddb67a6c6f610afbd87d3b658d377c51d9d43 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package main
import (
"fmt"
"os"
"git.thomasvoss.com/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)
}
}
}
|