-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.go
62 lines (51 loc) · 909 Bytes
/
cli.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package main
import (
"flag"
"fmt"
"log"
"os"
)
// Allow multiple string values for one flag
type stringsArray []string
func (s *stringsArray) String() string {
return fmt.Sprint(*s)
}
func (s *stringsArray) Set(value string) error {
*s = append(*s, value)
return nil
}
// Flags
var (
VarsList stringsArray
FilesList stringsArray
Strict bool
)
func initFlags() {
flag.Var(
&FilesList,
"f",
"Load variables from one or more JSON/TOML/YAML files (format: file path)",
)
flag.Var(
&VarsList,
"v",
"Use one or more variables from the command line (format: name=value)",
)
flag.BoolVar(
&Strict,
"s",
false,
"Strict mode. Raise errors if variables are missing (default: false)",
)
flag.Usage = func() {
log.Printf(
`USAGE: %s [OPTIONS] INPUT
INPUT is a template file or '-' for stdin
OPTIONS:
`,
os.Args[0],
)
flag.PrintDefaults()
}
flag.Parse()
}