mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Don't use default in command line args.
This commit is contained in:
parent
655b8f4db1
commit
31a37a4daf
1 changed files with 11 additions and 4 deletions
|
|
@ -17,14 +17,17 @@ import (
|
||||||
"github.com/csaf-poc/csaf_distribution/v2/internal/options"
|
"github.com/csaf-poc/csaf_distribution/v2/internal/options"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultPreset = "mandatory"
|
|
||||||
|
|
||||||
type outputFormat string
|
type outputFormat string
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultPreset = "mandatory"
|
||||||
|
defaultFormat = "json"
|
||||||
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
Output string `short:"o" long:"output" description:"File name of the generated report" value-name:"REPORT-FILE" toml:"output"`
|
Output string `short:"o" long:"output" description:"File name of the generated report" value-name:"REPORT-FILE" toml:"output"`
|
||||||
//lint:ignore SA5008 We are using choice twice: json, html.
|
//lint:ignore SA5008 We are using choice twice: json, html.
|
||||||
Format outputFormat `short:"f" long:"format" choice:"json" choice:"html" description:"Format of report" default:"json" toml:"format"`
|
Format outputFormat `short:"f" long:"format" choice:"json" choice:"html" description:"Format of report" toml:"format"`
|
||||||
Insecure bool `long:"insecure" description:"Do not check TLS certificates from provider" toml:"insecure"`
|
Insecure bool `long:"insecure" description:"Do not check TLS certificates from provider" toml:"insecure"`
|
||||||
ClientCert *string `long:"client-cert" description:"TLS client certificate file (PEM encoded data)" value-name:"CERT-FILE" toml:"client_cert"`
|
ClientCert *string `long:"client-cert" description:"TLS client certificate file (PEM encoded data)" value-name:"CERT-FILE" toml:"client_cert"`
|
||||||
ClientKey *string `long:"client-key" description:"TLS client private key file (PEM encoded data)" value-name:"KEY-FILE" toml:"client_key"`
|
ClientKey *string `long:"client-key" description:"TLS client private key file (PEM encoded data)" value-name:"KEY-FILE" toml:"client_key"`
|
||||||
|
|
@ -36,7 +39,7 @@ type config struct {
|
||||||
|
|
||||||
RemoteValidator string `long:"validator" description:"URL to validate documents remotely" value-name:"URL" toml:"validator"`
|
RemoteValidator string `long:"validator" description:"URL to validate documents remotely" value-name:"URL" toml:"validator"`
|
||||||
RemoteValidatorCache string `long:"validatorcache" description:"FILE to cache remote validations" value-name:"FILE" toml:"validator_cache"`
|
RemoteValidatorCache string `long:"validatorcache" description:"FILE to cache remote validations" value-name:"FILE" toml:"validator_cache"`
|
||||||
RemoteValidatorPresets []string `long:"validatorpreset" description:"One or more presets to validate remotely" default:"mandatory" toml:"validator_preset"`
|
RemoteValidatorPresets []string `long:"validatorpreset" description:"One or more presets to validate remotely" toml:"validator_preset"`
|
||||||
|
|
||||||
Config string `short:"c" long:"config" description:"Path to config TOML file" value-name:"TOML-FILE" toml:"-"`
|
Config string `short:"c" long:"config" description:"Path to config TOML file" value-name:"TOML-FILE" toml:"-"`
|
||||||
|
|
||||||
|
|
@ -72,10 +75,14 @@ func parseArgsConfig() ([]string, *config, error) {
|
||||||
},
|
},
|
||||||
Usage: "[OPTIONS] domain...",
|
Usage: "[OPTIONS] domain...",
|
||||||
SetDefaults: func(cfg *config) {
|
SetDefaults: func(cfg *config) {
|
||||||
|
cfg.Format = defaultFormat
|
||||||
cfg.RemoteValidatorPresets = []string{defaultPreset}
|
cfg.RemoteValidatorPresets = []string{defaultPreset}
|
||||||
},
|
},
|
||||||
// Re-establish default values if not set.
|
// Re-establish default values if not set.
|
||||||
EnsureDefaults: func(cfg *config) {
|
EnsureDefaults: func(cfg *config) {
|
||||||
|
if cfg.Format == "" {
|
||||||
|
cfg.Format = defaultFormat
|
||||||
|
}
|
||||||
if cfg.RemoteValidatorPresets == nil {
|
if cfg.RemoteValidatorPresets == nil {
|
||||||
cfg.RemoteValidatorPresets = []string{defaultPreset}
|
cfg.RemoteValidatorPresets = []string{defaultPreset}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue