From 36bc5175246932d25214db50b2df24c227127c5d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 19 Apr 2018 22:00:42 +0200 Subject: [PATCH] Add support for tagging/untagging multiple entries with one call --- bin/core/imag-tag/src/main.rs | 11 +++++++---- bin/core/imag-tag/src/ui.rs | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs index d291af69..8a131f8d 100644 --- a/bin/core/imag-tag/src/main.rs +++ b/bin/core/imag-tag/src/main.rs @@ -82,19 +82,22 @@ fn main() { "Direct interface to the store. Use with great care!", build_ui); - let id = rt.cli().value_of("id").map(PathBuf::from).unwrap(); // enforced by clap + let ids = rt.cli().values_of("id").unwrap().map(PathBuf::from); // enforced by clap + rt.cli() .subcommand_name() .map(|name| match name { - "list" => list(id, &rt), - "remove" => { + "list" => for id in ids { + list(id, &rt) + }, + "remove" => for id in ids { let id = PathBuf::from(id); let add = None; let rem = get_remove_tags(rt.cli()); debug!("id = {:?}, add = {:?}, rem = {:?}", id, add, rem); alter(&rt, id, add, rem); }, - "add" => { + "add" => for id in ids { let id = PathBuf::from(id); let add = get_add_tags(rt.cli()); let rem = None; diff --git a/bin/core/imag-tag/src/ui.rs b/bin/core/imag-tag/src/ui.rs index 48c1bd11..40643d40 100644 --- a/bin/core/imag-tag/src/ui.rs +++ b/bin/core/imag-tag/src/ui.rs @@ -25,8 +25,8 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app.arg(Arg::with_name("id") .index(1) .takes_value(true) - .required(true) - .multiple(false) + .required(false) + .multiple(true) .value_name("ID") .help("Entry to use"))