diff --git a/src/modes/info.rs b/src/modes/info.rs index 989450d..9554ee0 100644 --- a/src/modes/info.rs +++ b/src/modes/info.rs @@ -20,26 +20,22 @@ pub fn mode_info( cmd: &mut Command, settings: &config::Settings, ids: &mut Vec, - _tags: &mut Vec, + tags: &mut Vec, conn: &mut rusqlite::Connection, data_path: PathBuf, ) -> Result<()> { - // For --info, we only use IDs, tags should be empty - if ids.is_empty() && !_tags.is_empty() { - cmd.error(ErrorKind::InvalidValue, "Tags are not supported for --info, only IDs").exit(); + // For --info, we can use either IDs or tags, but not both + if !ids.is_empty() && !tags.is_empty() { + 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 { 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()); - // Use empty tags vector since --info only works with IDs + // Use empty metadata HashMap 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))?; show_item(item_with_meta, settings, data_path)