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:
@@ -398,7 +398,7 @@ impl ItemService {
|
||||
conn: &Connection,
|
||||
ids: &[i64],
|
||||
tags: &[String],
|
||||
meta: &HashMap<String, String>,
|
||||
meta: &HashMap<String, Option<String>>,
|
||||
) -> Result<ItemWithMeta, CoreError> {
|
||||
debug!("ITEM_SERVICE: Finding item with ids: {ids:?}, tags: {tags:?}, meta: {meta:?}");
|
||||
let item_maybe = match (ids.is_empty(), tags.is_empty() && meta.is_empty()) {
|
||||
@@ -466,7 +466,7 @@ impl ItemService {
|
||||
&self,
|
||||
conn: &Connection,
|
||||
tags: &[String],
|
||||
meta: &HashMap<String, String>,
|
||||
meta: &HashMap<String, Option<String>>,
|
||||
) -> Result<Vec<ItemWithMeta>, CoreError> {
|
||||
debug!("ITEM_SERVICE: Listing items with tags: {tags:?}, meta: {meta:?}");
|
||||
let items = db::get_items_matching(conn, &tags.to_vec(), meta)?;
|
||||
@@ -623,6 +623,13 @@ impl ItemService {
|
||||
for (k, v) in item_meta.iter() {
|
||||
db::add_meta(conn, item_id, k, v)?;
|
||||
}
|
||||
// Store user-specified metadata from --meta CLI flags
|
||||
for (key, value) in &settings.meta {
|
||||
if let Some(v) = value {
|
||||
debug!("ITEM_SERVICE: Setting user meta {key}={v}");
|
||||
db::add_meta(conn, item_id, key, v)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print the "KEEP: New item" message before starting to read input
|
||||
|
||||
Reference in New Issue
Block a user