-
Notifications
You must be signed in to change notification settings - Fork 4
/
flags.go
45 lines (35 loc) · 797 Bytes
/
flags.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
42
43
44
45
package main
import (
"flag"
"fmt"
"os"
)
var (
cliCmds argSlice
version bool
verbose bool
)
func init() {
flag.Var(&cliCmds, "c", "List of commands to execute")
flag.BoolVar(&verbose, "v", false, "Verbose output")
flag.BoolVar(&version, "version", false, "[DEPRECATED: use 'snag version'] display snag's version")
flag.Usage = func() {
usage := `Usage of %s:
%s [COMMAND]
Commands:
init Generate a snag file %q used for configuration and execution
version Display snag's version
Flags:
`
fmt.Fprintf(os.Stderr, usage, os.Args[0], os.Args[0], SnagFile)
flag.PrintDefaults()
}
}
type argSlice []string
func (c *argSlice) String() string {
return fmt.Sprintf("%s", *c)
}
func (a *argSlice) Set(value string) error {
*a = append(*a, value)
return nil
}