-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (38 loc) · 837 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Command ox-test.
package main
import (
"fmt"
"net/url"
"github.com/xo/ox"
)
func main() {
var (
arg string
u *url.URL
urlSet bool
ints []int
strings []string
m map[int]int
)
run := func(args []string) {
fmt.Println("arg:", arg)
if urlSet {
fmt.Println("u:", u)
} else {
fmt.Println("u: not set")
}
fmt.Println("ints:", ints)
fmt.Println("strings:", strings)
fmt.Println("map:", m)
}
ox.Run(
ox.Exec(run),
ox.Usage("ox-test", "ox test command"),
ox.Defaults(),
ox.Flags().
String("arg", "an arg", ox.Bind(&arg)).
URL("url", "a url", ox.Short("u"), ox.BindSet(&u, &urlSet)).
Slice("int", "a slice of ints", ox.Short("i"), ox.Uint64T, ox.Bind(&ints), ox.Bind(&strings)).
Map("map", "a map", ox.Short("m"), ox.Bind(&m), ox.IntT, ox.MapKey(ox.IntT)),
)
}