env

package
v1.232.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsBoolLiteral added in v1.232.0

func IsBoolLiteral(value string) bool

IsBoolLiteral reports whether value is exactly "true" or "false", ignoring case. Other spellings accepted by strconv.ParseBool, such as 1, 0, t, or f, are deliberately excluded because they are far more likely to be a positional argument than a boolean flag value. This package deliberately has no Atmos dependencies so the logger can use it during package initialization.

func IsColorEnabled

func IsColorEnabled() *bool

IsColorEnabled checks environment variables to determine if color should be enabled.

Returns:

  • false if NO_COLOR is set (disables color)
  • false if CLICOLOR=0 is set (disables color, unless forced)
  • true if CLICOLOR_FORCE or FORCE_COLOR is set (forces color)
  • nil if no color-related environment variables are set (caller should use TTY detection)

This function is designed for early initialization before flags or config are available. It only checks environment variables and has zero dependencies on other atmos packages.

func NormalizeBoolFlagValues added in v1.232.0

func NormalizeBoolFlagValues(args []string, isBoolFlag func(name string) bool) []string

NormalizeBoolFlagValues rewrites "--flag true|false" to "--flag=true|false" for flags that isBoolFlag reports as boolean.

Cobra/pflag boolean flags never consume the following argument, so "--no-color false" leaves "false" behind as a stray positional argument (an unknown command, or an argument forwarded to Terraform). Only the exact literals "true" and "false" (case-insensitive) are folded into the flag; any other following argument (a subcommand, a component name, another flag) is left alone so that a bare "--flag" keeps meaning "true".

The isBoolFlag callback receives the flag name without leading dashes: the long name for "--name" and the shorthand for "-n". Arguments that already carry a value ("--flag=false"), unknown flags, and everything after the "--" terminator are never modified. The input slice is not mutated; it is returned as-is when nothing needs rewriting.

func ResolveNoColor added in v1.232.0

func ResolveNoColor(args []string, viperNoColor bool) bool

ResolveNoColor reports whether color is globally disabled before Cobra has parsed flags.

Precedence: a non-empty NO_COLOR is absolute; otherwise an explicit --no-color flag (true or false) beats the ATMOS_NO_COLOR environment variable and any viper value derived from the environment; with no flag, ATMOS_NO_COLOR or the supplied viper value (for example one set by in-process callers) enables the opt-out. Args excludes the executable name.

Types

type ColorOptions added in v1.232.0

type ColorOptions struct {
	NoColor    bool
	NoColorSet bool
	LogsColor  string
}

ColorOptions contains the color overrides available before configuration loads.

func ColorOptionsFromArgs added in v1.232.0

func ColorOptionsFromArgs(args []string) ColorOptions

ColorOptionsFromArgs reads color overrides without consuming a command name as a boolean value. Args excludes the executable and parsing stops at --. This package deliberately has no Atmos dependencies so the logger can use it during package initialization, before any diagnostics are emitted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL