-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.go
64 lines (53 loc) · 1.38 KB
/
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
63
64
package viaduct
import (
"log"
flag "github.com/spf13/pflag"
)
// CliFlags configures the command-line toolset
type CliFlags struct {
Attributes bool
DryRun bool
DumpManifest bool
Quiet bool
Silent bool
}
// initCli loads command-line options
func initCli(c *CliFlags) {
var (
attributes bool
dryRun bool
dumpManifest bool
quiet bool
silent bool
)
flag.BoolVar(&dryRun, "dry-run", false, "Test changes with dry-run mode")
flag.BoolVar(&attributes, "attributes", false, "Display known attributes")
flag.BoolVar(&dumpManifest, "dump-manifest", false, "Dump the full manifest after the run")
flag.BoolVar(&quiet, "quiet", false, "Quiet mode will only display errors during a run")
flag.BoolVar(&silent, "silent", false, "Silent mode will suppress all output")
flag.Parse()
if silent && quiet {
log.Fatal("Cannot use --silent and --quiet together")
}
c.Attributes = attributes
c.DryRun = dryRun
c.DumpManifest = dumpManifest
c.Quiet = quiet
c.Silent = silent
}
// SetDryRun enables dry run mode.
func (c *CliFlags) SetDryRun() {
c.DryRun = true
}
// SetDumpManifest enables dumping the manifest.
func (c *CliFlags) SetDumpManifest() {
c.DumpManifest = true
}
// SetQuiet enables quiet mode.
func (c *CliFlags) SetQuiet() {
c.Quiet = true
}
// SetSilent enables silent mode.
func (c *CliFlags) SetSilent() {
c.Silent = true
}