summaryrefslogtreecommitdiffstats
path: root/libimagtag
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-03-18 15:24:11 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-03-18 15:24:11 +0100
commit142c1dfc5f95e34563ca4b7cae1b07a283d899c0 (patch)
tree60f1d8666a0de4f2dc09ea9260e56acf6a4b1df4 /libimagtag
parentcf20a23fec612ad8ced96694a5c8249226f82abd (diff)
Add tag helper to execute the CLI spec for an entry
Diffstat (limited to 'libimagtag')
-rw-r--r--libimagtag/src/exec.rs29
-rw-r--r--libimagtag/src/lib.rs1
2 files changed, 30 insertions, 0 deletions
diff --git a/libimagtag/src/exec.rs b/libimagtag/src/exec.rs
new file mode 100644
index 00000000..e9603d87
--- /dev/null
+++ b/libimagtag/src/exec.rs
@@ -0,0 +1,29 @@
+use clap::ArgMatches;
+
+use libimagstore::store::FileLockEntry;
+
+use result::Result;
+use tagable::*;
+use ui::{get_add_tags, get_remove_tags};
+
+pub fn exec_cli_for_entry(matches: &ArgMatches, entry: &mut FileLockEntry) -> Result<()> {
+ match get_add_tags(matches) {
+ Some(ts) => for t in ts {
+ if let Err(e) = entry.add_tag(t) {
+ return Err(e);
+ }
+ },
+ None => { },
+ }
+
+ match get_remove_tags(matches) {
+ Some(ts) => for t in ts {
+ if let Err(e) = entry.remove_tag(t) {
+ return Err(e);
+ }
+ },
+ None => { },
+ }
+
+ Ok(())
+}
diff --git a/libimagtag/src/lib.rs b/libimagtag/src/lib.rs
index f4d1c543..edded91b 100644
--- a/libimagtag/src/lib.rs
+++ b/libimagtag/src/lib.rs
@@ -6,6 +6,7 @@ extern crate toml;
extern crate libimagstore;
pub mod error;
+pub mod exec;
pub mod result;
pub mod tag;
pub mod tagable;