feat: allow --list to accept item IDs for filtering
- Local and client/server modes now support ID-based filtering - keep -l 1 2 3 lists specific items by ID - keep -l --ids-only 1 2 3 outputs just those IDs - Server API adds optional 'ids' query parameter to GET /api/item/ - KeepClient.list_items gains ids parameter
This commit is contained in:
@@ -81,28 +81,20 @@ struct ListItem {
|
||||
///
|
||||
/// * `Result<()>` - Success or error if listing fails.
|
||||
pub fn mode_list(
|
||||
cmd: &mut clap::Command,
|
||||
_cmd: &mut clap::Command,
|
||||
settings: &config::Settings,
|
||||
ids: &mut [i64],
|
||||
tags: &[String],
|
||||
conn: &mut rusqlite::Connection,
|
||||
data_path: std::path::PathBuf,
|
||||
) -> Result<()> {
|
||||
if !ids.is_empty() {
|
||||
cmd.error(
|
||||
clap::error::ErrorKind::InvalidValue,
|
||||
"ID given, you can only supply tags when using --list",
|
||||
)
|
||||
.exit();
|
||||
}
|
||||
|
||||
let item_service = ItemService::new(data_path.clone());
|
||||
let meta_filter: std::collections::HashMap<String, Option<String>> = settings
|
||||
.meta
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), v.clone()))
|
||||
.collect();
|
||||
let items_with_meta = item_service.list_items(conn, tags, &meta_filter)?;
|
||||
let items_with_meta = item_service.get_items(conn, ids, tags, &meta_filter)?;
|
||||
|
||||
if settings.ids_only {
|
||||
for item_with_meta in &items_with_meta {
|
||||
|
||||
Reference in New Issue
Block a user