#[non_exhaustive]pub struct CliEnv {
pub linesmith_config: Option<String>,
pub xdg_config_home: Option<String>,
pub home: Option<String>,
pub no_color: bool,
pub force_color: bool,
pub colorterm: Option<String>,
pub term: Option<String>,
pub terminal_width: Option<u16>,
pub color_capability: Option<Capability>,
pub cwd: Option<PathBuf>,
pub log_level_env: Option<String>,
}Expand description
Process-ambient inputs the CLI reads: env vars consulted by
resolve_config_path, the color-policy env flags, an optional
terminal-width override, and an optional color-capability
override. Passed through cli_main so tests can drive the whole
binary without touching the real process env. #[non_exhaustive]
leaves room for future env vars (TERM, …) without breaking
external construction.
Env snapshotting is the exclusive job of CliEnv::from_process.
CliEnv::default and CliEnv::for_tests do not read any
ambient state — the resolver honors only what the struct carries.
Production binaries must use from_process; callers passing
default() opt out of env awareness entirely (including
NO_COLOR / FORCE_COLOR / COLUMNS).
terminal_width = None means “detect lazily when the render path
needs it.” Meta commands (--help, --version, --check-config)
never probe the terminal, so stray COLUMNS warnings don’t leak
into clean stderr.
color_capability = Some(cap) bypasses the entire color-policy
precedence chain — reserved for test determinism. Production uses
None and lets no_color / force_color / config resolve it.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.linesmith_config: Option<String>§xdg_config_home: Option<String>§home: Option<String>§no_color: bool§force_color: bool§colorterm: Option<String>Raw COLORTERM, or None if unset. Threaded to the
force-color resolver so it can justify TrueColor when the TTY
probe gives up (e.g. piped stdout under Claude Code).
from_process snapshots the real env; for_tests/default
leave it None so ambient COLORTERM=truecolor can’t leak
into captured-output tests.
term: Option<String>Raw TERM, or None if unset. Same snapshot discipline as
colorterm.
terminal_width: Option<u16>§color_capability: Option<Capability>§cwd: Option<PathBuf>cwd used for gix repo discovery. None skips discovery
entirely. Self::from_process sets this to
std::env::current_dir(); Self::for_tests leaves it
None.
log_level_env: Option<String>Raw LINESMITH_LOG value, or None if unset. from_process
snapshots the real env; for_tests/default leave it None
so a developer’s ambient LINESMITH_LOG=debug can’t pollute
captured-stderr CLI tests.
Implementations§
Source§impl CliEnv
impl CliEnv
Sourcepub fn from_process() -> Self
pub fn from_process() -> Self
Snapshot the real process env vars. Terminal width and color
capability are left unset; run_cli probes them only if a
render happens.
Sourcepub fn for_tests() -> Self
pub fn for_tests() -> Self
Test-suite baseline: no env paths, color flags off,
terminal_width = Some(200), color_capability = Some(None).
Forces the capability override so stdout stays plain under a
truecolor host; tests that exercise the color-policy resolver
directly use CliEnv::default() instead.