-
Notifications
You must be signed in to change notification settings - Fork 1
/
args.go
45 lines (41 loc) · 1.05 KB
/
args.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 (
"os"
"strings"
)
type myArgs struct {
Apply bool
AllTemplates bool
Debug bool
Verbose bool
Kubeconfig bool
Help bool
Templates []string
Files []string
}
var args myArgs
func parseArgs() {
for _, arg := range os.Args[1:] {
if strings.HasPrefix(arg, "-") {
if strings.EqualFold(arg, "-all") {
args.AllTemplates = true
} else if strings.EqualFold(arg, "-apply") {
args.Apply = true
} else if strings.EqualFold(arg, "-kubeconfig") || strings.EqualFold(arg, "-kc") {
args.Kubeconfig = true
} else if strings.EqualFold(arg, "-debug") || strings.EqualFold(arg, "-d") {
args.Debug = true
} else if strings.EqualFold(arg, "-help") || strings.EqualFold(arg, "-h") {
args.Help = true
} else if strings.EqualFold(arg, "-verbose") || strings.EqualFold(arg, "-v") {
args.Verbose = true
} else {
args.Templates = append(args.Templates, arg[1:])
}
} else {
if _, err := os.Lstat(arg); err == nil {
args.Files = append(args.Files, arg)
}
}
}
}