feat: implement unified settings system
Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
@@ -157,12 +157,6 @@ impl FromStr for OutputFormat {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_output_format(args: &Args) -> OutputFormat {
|
||||
args.options.output_format
|
||||
.as_ref()
|
||||
.and_then(|s| OutputFormat::from_str(s).ok())
|
||||
.unwrap_or(OutputFormat::Table)
|
||||
}
|
||||
|
||||
pub fn cmd_args_meta_plugin_types(cmd: &mut Command, args: &Args) -> Vec<MetaPluginType> {
|
||||
let mut meta_plugin_types = Vec::new();
|
||||
@@ -200,3 +194,83 @@ pub fn cmd_args_meta_plugin_types(cmd: &mut Command, args: &Args) -> Vec<MetaPlu
|
||||
|
||||
meta_plugin_types
|
||||
}
|
||||
|
||||
pub fn settings_meta_plugin_types(cmd: &mut Command, settings: &crate::config::Settings) -> Vec<MetaPluginType> {
|
||||
let mut meta_plugin_types = Vec::new();
|
||||
|
||||
// Handle comma-separated values in each meta_plugins argument
|
||||
for meta_plugin_names_str in &settings.meta_plugins {
|
||||
let meta_plugin_names: Vec<&str> = meta_plugin_names_str.split(',').collect();
|
||||
|
||||
for name in meta_plugin_names {
|
||||
let trimmed_name = name.trim();
|
||||
if trimmed_name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try to find the MetaPluginType by meta name
|
||||
let mut found = false;
|
||||
for meta_plugin_type in MetaPluginType::iter() {
|
||||
let mut meta_plugin = crate::meta_plugin::get_meta_plugin(meta_plugin_type.clone());
|
||||
if meta_plugin.meta_name() == trimmed_name {
|
||||
meta_plugin_types.push(meta_plugin_type);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if !found {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Unknown meta plugin type: {}", trimmed_name),
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
meta_plugin_types
|
||||
}
|
||||
|
||||
pub fn settings_digest_type(cmd: &mut Command, settings: &crate::config::Settings) -> MetaPluginType {
|
||||
let digest_name = settings
|
||||
.digest
|
||||
.clone()
|
||||
.unwrap_or(MetaPluginType::DigestSha256.to_string());
|
||||
|
||||
let digest_type_opt = MetaPluginType::from_str(&digest_name);
|
||||
if digest_type_opt.is_err() {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Invalid digest algorithm '{}'. Use 'sha256' or 'md5'", digest_name),
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
|
||||
digest_type_opt.unwrap()
|
||||
}
|
||||
|
||||
pub fn settings_compression_type(cmd: &mut Command, settings: &crate::config::Settings) -> CompressionType {
|
||||
let compression_name = settings
|
||||
.compression
|
||||
.clone()
|
||||
.unwrap_or(CompressionType::LZ4.to_string());
|
||||
|
||||
let compression_type_opt = CompressionType::from_str(&compression_name);
|
||||
if compression_type_opt.is_err() {
|
||||
cmd.error(
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Invalid compression algorithm '{}'. Supported algorithms: lz4, gzip, xz, zstd", compression_name),
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
|
||||
compression_type_opt.unwrap()
|
||||
}
|
||||
|
||||
pub fn settings_output_format(settings: &crate::config::Settings) -> OutputFormat {
|
||||
settings.output_format
|
||||
.as_ref()
|
||||
.and_then(|s| OutputFormat::from_str(s).ok())
|
||||
.unwrap_or(OutputFormat::Table)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user