aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
29
akode-rs/cli/src/config_override_args.rs
Normal file
29
akode-rs/cli/src/config_override_args.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
//! Preserve config overrides across command boundaries without changing typed child arguments.
|
||||
|
||||
use crate::MultitoolCli;
|
||||
use clap::CommandFactory;
|
||||
use clap::FromArgMatches;
|
||||
use akode_utils_cli::collect_config_overrides;
|
||||
use std::ffi::OsString;
|
||||
|
||||
pub(super) fn try_parse_from(
|
||||
args: impl IntoIterator<Item = impl Into<OsString>>,
|
||||
) -> Result<MultitoolCli, clap::Error> {
|
||||
let args: Vec<OsString> = args.into_iter().map(Into::into).collect();
|
||||
let mut command = MultitoolCli::command();
|
||||
let mut matches = command.try_get_matches_from_mut(&args)?;
|
||||
crate::queue_cmd::validate_options(&command, &matches)?;
|
||||
let mut cli = MultitoolCli::from_arg_matches_mut(&mut matches)
|
||||
.map_err(|error| error.format(&mut command))?;
|
||||
if cli.subcommand.is_none() || cli.config_overrides.raw_overrides.is_empty() {
|
||||
return Ok(cli);
|
||||
}
|
||||
|
||||
// Keep child copies unchanged: dispatch merges apply them after feature overrides.
|
||||
cli.config_overrides = collect_config_overrides(MultitoolCli::command(), args)?;
|
||||
Ok(cli)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "config_override_args_tests.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user