pub struct CliConfig {
pub log_level: Option<String>,
pub no_progress: bool,
pub config_path: Option<String>,
}Expand description
Runtime configuration for CLI execution.
This struct holds configuration that would otherwise be set as environment variables, enabling dependency injection and better testability. It allows tests and programmatic usage to control CLI behavior without modifying global environment state.
§Design Rationale
Rather than directly setting environment variables in CLI parsing, this struct:
- Enables clean testing without global state pollution
- Allows configuration composition and validation
- Provides a single point for environment variable management
- Supports configuration serialization if needed
§Usage Pattern
let config = CliConfig::new()
.with_log_level("debug")
.with_no_progress(true);
config.apply_to_env();Fields§
§log_level: Option<String>Log level for the RUST_LOG environment variable.
Controls the verbosity of logging output throughout AGPM. Common values:
"error": Only errors are logged"warn": Errors and warnings"info": Errors, warnings, and informational messages"debug": All messages including debug information"trace": Maximum verbosity for troubleshooting
When None, the existing RUST_LOG value is preserved.
no_progress: boolWhether to disable progress indicators and animated output.
When true, sets the AGPM_NO_PROGRESS environment variable to disable:
- Progress bars during long operations
- Spinner animations
- Real-time status updates
This is useful for:
- Automated scripts and CI/CD pipelines
- Terminal environments that don’t support ANSI codes
- Debugging where animated output interferes with logs
config_path: Option<String>Custom path to the global configuration file.
When specified, sets the AGPM_CONFIG environment variable to override
the default configuration file location (~/.agpm/config.toml).
This enables:
- Testing with isolated configuration files
- Alternative configuration layouts
- Shared configuration in team environments
Implementations§
Source§impl CliConfig
impl CliConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new CLI configuration with default values.
Returns a configuration with:
- No log level override (
log_level: None) - Progress indicators enabled (
no_progress: false) - Default config file location (
config_path: None)
§Examples
use agpm_cli::cli::CliConfig;
let config = CliConfig::new();
assert_eq!(config.log_level, None);
assert_eq!(config.no_progress, false);
assert_eq!(config.config_path, None);Trait Implementations§
Auto Trait Implementations§
impl Freeze for CliConfig
impl RefUnwindSafe for CliConfig
impl Send for CliConfig
impl Sync for CliConfig
impl Unpin for CliConfig
impl UnwindSafe for CliConfig
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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