#[non_exhaustive]pub struct CliEnv {
pub linesmith_config: Option<OsString>,
pub xdg_config_home: Option<OsString>,
pub home: Option<OsString>,
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<OsString>Path-bearing fields are OsString (not String) because Unix
paths are byte-strings — a user with XDG_CONFIG_HOME=/srv/ café-bin in a non-UTF-8 locale must not silently lose their
setting. from_process uses var_os to preserve those bytes;
for_tests and Default leave them None.
xdg_config_home: Option<OsString>§home: Option<OsString>§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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CliEnv
impl RefUnwindSafe for CliEnv
impl Send for CliEnv
impl Sync for CliEnv
impl Unpin for CliEnv
impl UnsafeUnpin for CliEnv
impl UnwindSafe for CliEnv
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more