blob: 47aef199813cd55a0edb02c852dd2f64aac58331 (
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"
"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)
}
}
}
|