Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func EnvHelp(w io.Writer) {
// For a server with dynamic flags, call ServerMain instead.
// Will either have called [ExitFunction] (defaults to [os.Exit])
// or returned if all validations passed.
func Main() {
func Main() { //nolint: funlen // just over 70 lines
quietFlag := flag.Bool("quiet", false,
"Quiet mode, sets loglevel to Error (quietly) to reduces the output")
flag.BoolVar(&log.Config.ForceColor, "logger-force-color", false,
Expand Down Expand Up @@ -160,7 +160,6 @@ func Main() {
ArgsHelp = " " + ArgsHelp
}
if !ServerMode {
log.SetDefaultsForClientTools()
log.LoggerStaticFlagSetup("loglevel")
}
flag.CommandLine.Usage = func() { usage(os.Stderr, "") } // flag handling will exit 1 after calling usage, except for -h/-help
Expand Down Expand Up @@ -197,6 +196,12 @@ func Main() {
os.Stderr.WriteString(log.Colors.BrightRed)
flag.Parse()
os.Stderr.WriteString(log.Colors.Reset)
if *quietFlag {
log.SetLogLevelQuiet(log.Error)
}
if !ServerMode {
log.SetDefaultsForClientTools()
}
if *nocolor {
// Don't override the env if the flag isn't set
// (downside is if LOGGER_CONSOLE_COLOR is set to false, this -logger-no-color=false can't override it)
Expand Down Expand Up @@ -224,9 +229,6 @@ func Main() {
errArgCount(exactly, MaxArgs, nArgs)
return // not typically reached, unless ExitFunction doesn't exit
}
if *quietFlag {
log.SetLogLevelQuiet(log.Error)
}
}

func errArgCount(prefix string, expected, actual int) {
Expand Down