diff options
| -rw-r--r-- | cmd/silentct-mon/main.go | 34 | 
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 { | 
