feat: add tag support to --info mode

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-29 14:25:21 -03:00
parent 692a403a7e
commit bf5ea8dc08

View File

@@ -20,26 +20,22 @@ pub fn mode_info(
cmd: &mut Command, cmd: &mut Command,
settings: &config::Settings, settings: &config::Settings,
ids: &mut Vec<i64>, ids: &mut Vec<i64>,
_tags: &mut Vec<String>, tags: &mut Vec<String>,
conn: &mut rusqlite::Connection, conn: &mut rusqlite::Connection,
data_path: PathBuf, data_path: PathBuf,
) -> Result<()> { ) -> Result<()> {
// For --info, we only use IDs, tags should be empty // For --info, we can use either IDs or tags, but not both
if ids.is_empty() && !_tags.is_empty() { if !ids.is_empty() && !tags.is_empty() {
cmd.error(ErrorKind::InvalidValue, "Tags are not supported for --info, only IDs").exit(); cmd.error(ErrorKind::InvalidValue, "Both ID and tags given, you must supply either IDs or tags when using --info").exit();
} else if ids.len() > 1 { } else if ids.len() > 1 {
cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID when using --info").exit(); cmd.error(ErrorKind::InvalidValue, "More than one ID given, you must supply exactly one ID when using --info").exit();
} else if ids.is_empty() {
// If no ID is provided, find the last item
// This matches the behavior in find_item when (true, true)
// Clear the ids vector to ensure find_item uses the last item
ids.clear();
} }
// If both are empty, find_item will find the last item
let item_service = ItemService::new(data_path.clone()); let item_service = ItemService::new(data_path.clone());
// Use empty tags vector since --info only works with IDs // Use empty metadata HashMap
let item_with_meta = item_service let item_with_meta = item_service
.find_item(conn, ids, _tags, &std::collections::HashMap::new()) .find_item(conn, ids, tags, &std::collections::HashMap::new())
.map_err(|e| anyhow!("Unable to find matching item in database: {}", e))?; .map_err(|e| anyhow!("Unable to find matching item in database: {}", e))?;
show_item(item_with_meta, settings, data_path) show_item(item_with_meta, settings, data_path)