go: add a way to reduce printing
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9b4aa6e370
commit
7c8650019e
@ -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
|
||||
}
|
||||
|
22
run.go
22
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"
|
||||
|
Loading…
Reference in New Issue
Block a user