diff --git a/README.md b/README.md index 69a31ad..3fc647b 100644 --- a/README.md +++ b/README.md @@ -47,19 +47,10 @@ Messages are written into standard error stream (`stderr`) to avoid polluting th
## Features +- Coloured output by default with emojis - Prints to Standard Error stream (`stderr`) - Subprocess friendly: Tries to access the `tty` and print to its `stderr` (can be disabled) -- Message structure: - 1. `emoji` (optional, pass empty string to ignore it) - 2. `...args` (often just a single string) -- Coloured output by default with emojis -- Respectful of user environment and disables color output with emojis if one of below set: - - `NO_COLOR` (to something other than `false` or `0`) - - `_NO_COLOR` (to something other than `false` or `0`) - - `TERM=dumb` -- Allows user to control verbosity by configuring environment variables: - - `VERBOSE` (to something other than `false` or `0`) - - `_VERBOSE` (to something other than `false` or `0`) +- Respectful of user environment: User can disable colors/emojis, enable silent mode or verbose mode by setting various environment variables.
diff --git a/setup.go b/setup.go index b723a66..f59b754 100644 --- a/setup.go +++ b/setup.go @@ -148,12 +148,10 @@ func allowEmoji(appName string) bool { // enableVerboseMode sets the initial verbosity setting by looking at the user // environment for specific variables. func enableVerboseMode(appName string) bool { - // Check if NO_COLOR set https://no-color.org/ if isEnvVarSetOrTruthy("VERBOSE") { return true } - // Check if app-specific _NO_COLOR set https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46 if isEnvVarSetOrTruthy(formatPrefixedEnvVar(appName, "VERBOSE")) { return true } @@ -164,19 +162,19 @@ func enableVerboseMode(appName string) bool { func isEnvVarSetOrTruthy(envVar string) bool { value, set := os.LookupEnv(envVar) - // if it's not set at all + // check if not set at all if !set { return false } - // if it has truthy value + // check if falsy value lowerValue := strings.ToLower(value) - if lowerValue == "true" || lowerValue == "1" { - return true + if lowerValue == "false" || lowerValue == "0" { + return false } - // for unset or "falsy value" - return false + // is set (or has truthy value) + return true } func formatPrefixedEnvVar(prefix string, envVar string) string {