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
|
// authSecretIsHex is used to recall whether the encryption secret was
|
||||||
// determined to be pure hex.
|
// determined to be pure hex.
|
||||||
encrSecretIsHex bool
|
encrSecretIsHex bool
|
||||||
|
quiet bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func Load(conf string, isPath bool) (*Config, error) {
|
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")
|
log.Debug("set DEBUG level based on config value")
|
||||||
|
|
||||||
slogger = slogging.SetLevel(slogging.LevelDebug)
|
slogger = slogging.SetLevel(slogging.LevelDebug)
|
||||||
@ -278,3 +279,8 @@ func dhallCmdExists() bool {
|
|||||||
|
|
||||||
return true
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip printing program header.
|
// skip printing program header and some other stuff.
|
||||||
skipHeader := false
|
shortCircuit := false
|
||||||
|
|
||||||
var doingImport bool
|
var doingImport bool
|
||||||
|
|
||||||
if importFlag != nil && *importFlag != "" {
|
if importFlag != nil && *importFlag != "" {
|
||||||
doingImport = true
|
doingImport = true
|
||||||
skipHeader = true
|
shortCircuit = true
|
||||||
|
|
||||||
|
config.BeQuiet()
|
||||||
}
|
}
|
||||||
|
|
||||||
if *printMigrationFlag {
|
if *printMigrationFlag {
|
||||||
skipHeader = true
|
shortCircuit = true
|
||||||
|
|
||||||
|
config.BeQuiet()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !skipHeader {
|
if !shortCircuit {
|
||||||
printHeader()
|
printHeader()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,9 +137,11 @@ func run() error { //nolint:gocognit
|
|||||||
|
|
||||||
setting := settings.New()
|
setting := settings.New()
|
||||||
|
|
||||||
setting.Consolidate(
|
if !shortCircuit {
|
||||||
conf, hostFlag, portFlag, develFlag, version,
|
setting.Consolidate(
|
||||||
)
|
conf, hostFlag, portFlag, develFlag, version,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// expected connstring form for "github.com/xiaoqidun/entps":
|
// expected connstring form for "github.com/xiaoqidun/entps":
|
||||||
// "file:ent?mode=memory&cache=shared&_fk=1"
|
// "file:ent?mode=memory&cache=shared&_fk=1"
|
||||||
|
Loading…
Reference in New Issue
Block a user