Don't wrap args.item.meta with option
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -111,7 +111,7 @@ struct ModeArgs {
|
||||
struct ItemArgs {
|
||||
#[arg(help_heading("Item Options"), short, long, conflicts_with_all(["get", "delete", "status"]))]
|
||||
#[arg(help("Set metadata for the item using the format KEY=[VALUE], the metadata will be removed if VALUE is not provided"))]
|
||||
meta: Option<Vec<KeyValue>>,
|
||||
meta: Vec<KeyValue>,
|
||||
|
||||
#[arg(help_heading("Item Options"), short('C'), long, env("KEEP_COMPRESSION"), )]
|
||||
#[arg(help("Compression algorithm to use when saving items"))]
|
||||
@@ -341,11 +341,9 @@ fn mode_save(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<S
|
||||
item_meta.insert("hostname".to_string(), hostname);
|
||||
}
|
||||
|
||||
if args.item.meta.is_some() {
|
||||
for item in args.item.meta.unwrap().iter() {
|
||||
let item = item.clone();
|
||||
item_meta.insert(item.key, item.value);
|
||||
}
|
||||
for item in args.item.meta.iter() {
|
||||
let item = item.clone();
|
||||
item_meta.insert(item.key, item.value);
|
||||
}
|
||||
|
||||
for kv in item_meta.iter() {
|
||||
@@ -405,11 +403,9 @@ fn mode_get(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<St
|
||||
}
|
||||
|
||||
let mut meta: HashMap<String, String> = HashMap::new();
|
||||
if args.item.meta.is_some() {
|
||||
for item in args.item.meta.unwrap().iter() {
|
||||
let item = item.clone();
|
||||
meta.insert(item.key, item.value);
|
||||
}
|
||||
for item in args.item.meta.iter() {
|
||||
let item = item.clone();
|
||||
meta.insert(item.key, item.value);
|
||||
}
|
||||
|
||||
let item_maybe = match tags.is_empty() && meta.is_empty() {
|
||||
@@ -443,11 +439,9 @@ fn mode_list(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &Vec<Strin
|
||||
}
|
||||
|
||||
let mut meta: HashMap<String, String> = HashMap::new();
|
||||
if args.item.meta.is_some() {
|
||||
for item in args.item.meta.unwrap().iter() {
|
||||
let item = item.clone();
|
||||
meta.insert(item.key, item.value);
|
||||
}
|
||||
for item in args.item.meta.iter() {
|
||||
let item = item.clone();
|
||||
meta.insert(item.key, item.value);
|
||||
}
|
||||
|
||||
|
||||
@@ -562,9 +556,9 @@ fn mode_update(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec
|
||||
db::set_item_tags(conn, item.clone(), tags)?;
|
||||
}
|
||||
|
||||
if args.item.meta.is_some() {
|
||||
if args.item.meta.len() > 0 {
|
||||
debug!("MAIN: Updating item meta");
|
||||
for kv in args.item.meta.unwrap().iter() {
|
||||
for kv in args.item.meta.iter() {
|
||||
let meta = db::Meta {
|
||||
id: item.id.unwrap(),
|
||||
name: kv.key.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user