feat: add --update mode, --meta/--meta-plugin flags, streaming diff
- Add --update mode to modify tags and metadata for existing items by ID
- Add --meta key=value flag to set metadata during save/update
- Add --meta key (bare) to delete metadata keys or filter by existence
- Add --meta-plugin/-M name:{json} flag for plugin options via CLI
- Env meta plugin now uses options from --meta-plugin instead of only env vars
- Stream decompressed content to diff via /dev/fd pipes (no temp files)
- Wire --list-format CLI arg to settings (was parsed but ignored)
- Allow --info to accept tags (was restricted to numeric IDs only)
- Change DB meta filtering to HashMap<String, Option<String>> for exact match + key existence
- Fix fcntl error checking in diff pre_exec
- Fix README inaccuracies (delete by tag, nonexistent --digest flag, meta plugin key names)
This commit is contained in:
11
src/db.rs
11
src/db.rs
@@ -912,7 +912,7 @@ pub fn get_items(conn: &Connection) -> Result<Vec<Item>> {
|
||||
/// let db_path = PathBuf::from("keep.db");
|
||||
/// let conn = db::open(db_path)?;
|
||||
/// let tags = vec!["project".to_string()];
|
||||
/// let meta = HashMap::from([("status".to_string(), "active".to_string())]);
|
||||
/// let meta = HashMap::from([("status".to_string(), Some("active".to_string()))]);
|
||||
/// let matching = db::get_items_matching(&conn, &tags, &meta)?;
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
@@ -920,7 +920,7 @@ pub fn get_items(conn: &Connection) -> Result<Vec<Item>> {
|
||||
pub fn get_items_matching(
|
||||
conn: &Connection,
|
||||
tags: &Vec<String>,
|
||||
meta: &HashMap<String, String>,
|
||||
meta: &HashMap<String, Option<String>>,
|
||||
) -> Result<Vec<Item>> {
|
||||
debug!("DB: Getting items matching: tags={tags:?} meta={meta:?}");
|
||||
|
||||
@@ -947,7 +947,10 @@ pub fn get_items_matching(
|
||||
Some(m) => m,
|
||||
None => return false,
|
||||
};
|
||||
meta.iter().all(|(k, v)| item_meta.get(k) == Some(v))
|
||||
meta.iter().all(|(k, v)| match v {
|
||||
Some(val) => item_meta.get(k) == Some(val),
|
||||
None => item_meta.contains_key(k),
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
Ok(filtered_items)
|
||||
@@ -990,7 +993,7 @@ pub fn get_items_matching(
|
||||
pub fn get_item_matching(
|
||||
conn: &Connection,
|
||||
tags: &Vec<String>,
|
||||
meta: &HashMap<String, String>,
|
||||
meta: &HashMap<String, Option<String>>,
|
||||
) -> Result<Option<Item>> {
|
||||
debug!("DB: Get item matching tags: {tags:?}, meta: {meta:?}");
|
||||
let items = get_items_matching(conn, tags, meta)?;
|
||||
|
||||
Reference in New Issue
Block a user