Add tag helper to execute the CLI spec for an entry

This commit is contained in:
Matthias Beyer 2016-03-18 15:24:11 +01:00
parent cf20a23fec
commit 142c1dfc5f
2 changed files with 30 additions and 0 deletions

29
libimagtag/src/exec.rs Normal file
View file

@ -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(())
}

View file

@ -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;