...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package driver
16
17 import (
18 "flag"
19 "strings"
20 )
21
22
23 type GoFlags struct {
24 UsageMsgs []string
25 }
26
27
28 func (*GoFlags) Bool(o string, d bool, c string) *bool {
29 return flag.Bool(o, d, c)
30 }
31
32
33 func (*GoFlags) Int(o string, d int, c string) *int {
34 return flag.Int(o, d, c)
35 }
36
37
38 func (*GoFlags) Float64(o string, d float64, c string) *float64 {
39 return flag.Float64(o, d, c)
40 }
41
42
43 func (*GoFlags) String(o, d, c string) *string {
44 return flag.String(o, d, c)
45 }
46
47
48 func (*GoFlags) StringList(o, d, c string) *[]*string {
49 return &[]*string{flag.String(o, d, c)}
50 }
51
52
53 func (f *GoFlags) ExtraUsage() string {
54 return strings.Join(f.UsageMsgs, "\n")
55 }
56
57
58 func (f *GoFlags) AddExtraUsage(eu string) {
59 f.UsageMsgs = append(f.UsageMsgs, eu)
60 }
61
62
63 func (*GoFlags) Parse(usage func()) []string {
64 flag.Usage = usage
65 flag.Parse()
66 args := flag.Args()
67 if len(args) == 0 {
68 usage()
69 }
70 return args
71 }
72
View as plain text