#[derive(Debug, Clone, Copy)]
pub struct Configuration {
pub(crate) verbose: bool,
pub(crate) log: bool,
pub(crate) allow_uncontained: bool,
pub(crate) compile_agents: bool,
pub(crate) self_test: bool,
pub(crate) test_all_configs: bool,
pub(crate) debug_agent_stderr: bool,
}
impl Configuration {
pub fn new() -> Self {
Self {
verbose: true,
log: false,
allow_uncontained: false,
compile_agents: true,
self_test: false,
test_all_configs: false,
debug_agent_stderr: false, }
}
pub fn from_env() -> Self {
fn get_env_flag(var: &str, default: bool) -> bool {
match std::env::var(var) {
Ok(val) => val.eq_ignore_ascii_case("true"),
Err(_) => default,
}
}
Self {
verbose: get_env_flag("EVAL_VERBOSE", true),
log: get_env_flag("EVAL_LOG", false),
allow_uncontained: get_env_flag("EVAL_ALLOW_UNCONTAINED", false),
compile_agents: get_env_flag("EVAL_COMPILE_AGENTS", true),
self_test: get_env_flag("EVAL_SELF_TEST", false),
test_all_configs: get_env_flag("EVAL_TEST_ALL_CONFIGS", false),
debug_agent_stderr: get_env_flag("EVAL_DEBUG_AGENT_STDERR", false),
}
}
pub fn with_verbose(mut self, value: bool) -> Self {
self.verbose = value;
self
}
pub fn with_log(mut self, value: bool) -> Self {
self.log = value;
self
}
pub fn with_allow_uncontained(mut self, value: bool) -> Self {
self.allow_uncontained = value;
self
}
pub fn with_compile_agents(mut self, value: bool) -> Self {
self.compile_agents = value;
self
}
pub fn with_self_test(mut self, value: bool) -> Self {
self.self_test = value;
self
}
pub fn with_test_all_configs(mut self, value: bool) -> Self {
self.test_all_configs = value;
self
}
pub fn with_debug_agent_stderr(mut self, value: bool) -> Self {
self.debug_agent_stderr = value;
self
}
}
impl Default for Configuration {
fn default() -> Self {
Self::new()
}
}