aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@rgdd.se>2024-05-19 13:24:00 +0200
committerRasmus Dahlberg <rasmus@rgdd.se>2024-05-19 13:24:50 +0200
commitce1ca03f9fead7f68063f224a7e835b6a3652b58 (patch)
treeabba4445d807ce0a001577d07c003765c92c7a66
parent5f852f11aed124df274d0c5257ec12f4e6373e7d (diff)
Sort options in lexicographical order
-rw-r--r--cmd/silentct-mon/main.go34
1 files changed, 17 insertions, 17 deletions
diff --git a/cmd/silentct-mon/main.go b/cmd/silentct-mon/main.go
index cc0ef77..2cb325a 100644
--- a/cmd/silentct-mon/main.go
+++ b/cmd/silentct-mon/main.go
@@ -40,12 +40,12 @@ Options:
-C, --contact A string that helps log operators know who you are,
consider seting this to an email address (Default: "")
-d, --directory Path to a directory where all state will be stored
+ -e, --please-exit Toggle to only run until up-to-date (Default: false)
-f, --force Override santity checks that may not be fatal (Default: false)
- -w, --num-workers Number of parallel workers to fetch each log with (Default: 1)
-o, --output-file File that all output will be written to (Default: stdout)
- -e, --please-exit Toggle to only run until up-to-date (Default: false)
-p, --pull-interval How often nodes are pulled for certificates (Default: 15m)
-v, --verbosity Leveled logging output (default: NOTICE)
+ -w, --num-workers Number of parallel workers to fetch each log with (Default: 1)
`
type config struct {
@@ -55,8 +55,8 @@ type config struct {
configFile string
contact string
directory string
- force bool
pleaseExit bool
+ force bool
outputFile string
pullInterval time.Duration
numWorkers uint
@@ -73,29 +73,17 @@ func configure(cmd string, args []string) (cfg config, err error) {
flagopt.StringOpt(fs, &cfg.configFile, "configuration", "c", "")
flagopt.StringOpt(fs, &cfg.contact, "contact", "C", "")
flagopt.StringOpt(fs, &cfg.directory, "directory", "d", "")
+ flagopt.BoolOpt(fs, &cfg.pleaseExit, "please-exit", "e", false)
flagopt.BoolOpt(fs, &cfg.force, "force", "f", false)
- flagopt.UintOpt(fs, &cfg.numWorkers, "num-workers", "w", 1)
flagopt.StringOpt(fs, &cfg.outputFile, "output-file", "o", "")
- flagopt.BoolOpt(fs, &cfg.pleaseExit, "please-exit", "e", false)
flagopt.DurationOpt(fs, &cfg.pullInterval, "pull-interval", "p", 15*time.Minute)
flagopt.StringOpt(fs, &cfg.verbosity, "verbosity", "v", logger.LevelNotice.String())
+ flagopt.UintOpt(fs, &cfg.numWorkers, "num-workers", "w", 1)
if err = fs.Parse(args); err != nil {
return cfg, err
}
// Options
- if cfg.directory == "" {
- return cfg, fmt.Errorf("directory is a required option")
- }
- if (cfg.numWorkers == 0 || cfg.numWorkers >= 4) && !cfg.force {
- return cfg, fmt.Errorf("number of workers must be in [1, 4)")
- }
- output := os.Stdout
- if cfg.outputFile != "" {
- if output, err = os.OpenFile(cfg.outputFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644); err != nil {
- return cfg, fmt.Errorf("failed to open output file: %v", err)
- }
- }
if cfg.configFile == "" {
return cfg, fmt.Errorf("configuration is a required option")
}
@@ -105,11 +93,23 @@ func configure(cmd string, args []string) (cfg config, err error) {
if len(cfg.policy.Monitor) == 0 {
return cfg, fmt.Errorf("configuration: need at least one wildcard to monitor")
}
+ if cfg.directory == "" {
+ return cfg, fmt.Errorf("directory is a required option")
+ }
+ output := os.Stdout
+ if cfg.outputFile != "" {
+ if output, err = os.OpenFile(cfg.outputFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644); err != nil {
+ return cfg, fmt.Errorf("failed to open output file: %v", err)
+ }
+ }
lv, err := logger.NewLevel(cfg.verbosity)
if err != nil {
return cfg, fmt.Errorf("invalid verbosity: %v", err)
}
cfg.log = logger.New(logger.Config{Level: lv, File: output})
+ if (cfg.numWorkers == 0 || cfg.numWorkers >= 4) && !cfg.force {
+ return cfg, fmt.Errorf("number of workers must be in [1, 4)")
+ }
// Arguments
if len(fs.Args()) != 0 {