pub struct ConfigResolver {
pub cli_flags: HashMap<String, Option<String>>,
pub config_file: Option<HashMap<String, String>>,
pub defaults: HashMap<&'static str, &'static str>,
/* private fields */
}Expand description
Resolved configuration following 4-tier precedence:
- CLI flags — highest priority
- Environment variables
- Config file (YAML, dot-flattened keys)
- Built-in defaults — lowest priority
Fields§
§cli_flags: HashMap<String, Option<String>>CLI flags map (flag name → value or None if not provided).
config_file: Option<HashMap<String, String>>Flattened key → value map loaded from the config file.
None if the file was not found or could not be parsed.
defaults: HashMap<&'static str, &'static str>Built-in default values.
Implementations§
Source§impl ConfigResolver
impl ConfigResolver
Sourcepub const DEFAULTS: &'static [(&'static str, &'static str)]
pub const DEFAULTS: &'static [(&'static str, &'static str)]
Default configuration values.
Audit D9 (config cleanup, v0.6.x): the entries sandbox.enabled,
cli.auto_approve, cli.stdin_buffer_limit, and the four
apcore-cli.* namespace aliases were removed because no production
code path reads them via resolve(). Sandbox is configured via the
--sandbox CLI flag, auto-approve via --yes, the stdin buffer is
hard-coded, and namespace aliases are registered separately by
apcore’s Config Bus when the parent crate calls
apcore::Config::register_namespace. The cross-key file-lookup
mechanism (alternate_key) still works regardless — it does not
depend on these DEFAULTS entries.
Sourcepub fn new(
cli_flags: Option<HashMap<String, Option<String>>>,
config_path: Option<PathBuf>,
) -> Self
pub fn new( cli_flags: Option<HashMap<String, Option<String>>>, config_path: Option<PathBuf>, ) -> Self
Create a new ConfigResolver.
§Arguments
cli_flags— CLI flag overrides (e.g.--extensions-dir → /path)config_path— Optional explicit path toapcore.yaml
Sourcepub fn resolve(
&self,
key: &str,
cli_flag: Option<&str>,
env_var: Option<&str>,
) -> Option<String>
pub fn resolve( &self, key: &str, cli_flag: Option<&str>, env_var: Option<&str>, ) -> Option<String>
Resolve a configuration value using 4-tier precedence.
§Arguments
key— dot-separated config key (e.g."extensions.root")cli_flag— optional CLI flag name to check in_cli_flagsenv_var— optional environment variable name
Returns None when the key is not present in any tier.
Sourcepub fn resolve_object(&self, key: &str) -> Option<Value>
pub fn resolve_object(&self, key: &str) -> Option<Value>
Resolve a non-leaf (object-valued) key from the YAML config file.
Unlike Self::resolve, which returns a flattened scalar string,
this returns the raw serde_yaml::Value living at the requested
dot-path. Used by FE-13 (apcli) where the top-level key can be a
bool, a mapping, or absent.
Only consults the config file (Tier 3) — CLI flags and env vars
carry scalar values only. Returns None when the file is absent,
unreadable, malformed, or the key is missing.