diff --git a/config/config.go b/config/config.go index 262b09f..3cbca88 100644 --- a/config/config.go +++ b/config/config.go @@ -100,6 +100,7 @@ var ( // authSecretIsHex is used to recall whether the encryption secret was // determined to be pure hex. encrSecretIsHex bool + quiet bool ) func Load(conf string, isPath bool) (*Config, error) { @@ -141,7 +142,7 @@ func Load(conf string, isPath bool) (*Config, error) { ) } - if config.DevelMode && os.Getenv("PCMT_DEVEL") != "False" { + if config.DevelMode && os.Getenv("PCMT_DEVEL") != "False" && !quiet { log.Debug("set DEBUG level based on config value") slogger = slogging.SetLevel(slogging.LevelDebug) @@ -278,3 +279,8 @@ func dhallCmdExists() bool { return true } + +// BeQuiet instruct this package to be more frugal with logging/printing info. +func BeQuiet() { + quiet = true +} diff --git a/run.go b/run.go index bea1d69..e3c5a34 100644 --- a/run.go +++ b/run.go @@ -80,21 +80,25 @@ func run() error { //nolint:gocognit return nil } - // skip printing program header. - skipHeader := false + // skip printing program header and some other stuff. + shortCircuit := false var doingImport bool if importFlag != nil && *importFlag != "" { doingImport = true - skipHeader = true + shortCircuit = true + + config.BeQuiet() } if *printMigrationFlag { - skipHeader = true + shortCircuit = true + + config.BeQuiet() } - if !skipHeader { + if !shortCircuit { printHeader() } @@ -133,9 +137,11 @@ func run() error { //nolint:gocognit setting := settings.New() - setting.Consolidate( - conf, hostFlag, portFlag, develFlag, version, - ) + if !shortCircuit { + setting.Consolidate( + conf, hostFlag, portFlag, develFlag, version, + ) + } // expected connstring form for "github.com/xiaoqidun/entps": // "file:ent?mode=memory&cache=shared&_fk=1"