feat: implement unified settings system

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-15 16:36:58 -03:00
parent 067cba703b
commit 56f4d8aad5
12 changed files with 283 additions and 140 deletions

View File

@@ -19,7 +19,8 @@ use prettytable::{Attr, Cell, Row, Table};
pub fn mode_info(
cmd: &mut Command,
args: &crate::Args,
settings: &crate::config::Settings,
_config: &crate::config::Config,
ids: &mut Vec<i64>,
tags: &mut Vec<String>,
conn: &mut rusqlite::Connection,
@@ -32,7 +33,7 @@ pub fn mode_info(
}
let mut meta: std::collections::HashMap<String, String> = std::collections::HashMap::new();
for item in args.item.meta.iter() {
for item in settings.meta.iter() {
let item = item.clone();
meta.insert(item.key, item.value);
}
@@ -46,7 +47,7 @@ pub fn mode_info(
};
match item_maybe {
Some(item) => show_item(item, args, conn, data_path),
Some(item) => show_item(item, settings, conn, data_path),
None => Err(anyhow!("Unable to find matching item in database")),
}
}
@@ -67,7 +68,7 @@ struct ItemInfo {
fn show_item(
item: Item, // Using the provided struct definition
args: &crate::Args,
settings: &crate::config::Settings,
conn: &mut rusqlite::Connection,
data_path: PathBuf,
) -> anyhow::Result<()> {
@@ -78,10 +79,10 @@ fn show_item(
.map(|x| x.name)
.collect();
let output_format = get_output_format(args);
let output_format = crate::modes::common::settings_output_format(settings);
if output_format != OutputFormat::Table {
return show_item_structured(item, args, conn, data_path, output_format);
return show_item_structured(item, settings, conn, data_path, output_format);
}
let mut table = Table::new();
@@ -111,7 +112,7 @@ fn show_item(
]));
let size_cell = match item.size {
Some(size) => Cell::new(format_size(size as u64, args.options.human_readable).as_str()),
Some(size) => Cell::new(format_size(size as u64, settings.human_readable).as_str()),
None => Cell::new("Missing")
.with_style(Attr::ForegroundColor(prettytable::color::RED))
.with_style(Attr::Bold),
@@ -132,7 +133,7 @@ fn show_item(
let file_size_cell = match item_path_buf.metadata() {
Ok(metadata) => {
Cell::new(format_size(metadata.len(), args.options.human_readable).as_str())
Cell::new(format_size(metadata.len(), settings.human_readable).as_str())
}
Err(_) => Cell::new("Missing")
.with_style(Attr::ForegroundColor(prettytable::color::RED))
@@ -162,7 +163,7 @@ fn show_item(
fn show_item_structured(
item: Item,
args: &crate::Args,
settings: &crate::config::Settings,
conn: &mut rusqlite::Connection,
data_path: PathBuf,
output_format: OutputFormat,
@@ -178,12 +179,12 @@ fn show_item_structured(
let file_size = item_path_buf.metadata().map(|m| m.len()).ok();
let file_size_formatted = match file_size {
Some(size) => format_size(size, args.options.human_readable),
Some(size) => format_size(size, settings.human_readable),
None => "Missing".to_string(),
};
let stream_size_formatted = match item.size {
Some(size) => format_size(size as u64, args.options.human_readable),
Some(size) => format_size(size as u64, settings.human_readable),
None => "Missing".to_string(),
};