2016-03-18 14:24:11 +00:00
|
|
|
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<()> {
|
2016-05-03 21:10:32 +00:00
|
|
|
if let Some(ts) = get_add_tags(matches) {
|
|
|
|
for t in ts {
|
2016-03-18 14:24:11 +00:00
|
|
|
if let Err(e) = entry.add_tag(t) {
|
|
|
|
return Err(e);
|
|
|
|
}
|
2016-05-03 21:10:32 +00:00
|
|
|
}
|
2016-03-18 14:24:11 +00:00
|
|
|
}
|
|
|
|
|
2016-05-03 21:10:32 +00:00
|
|
|
if let Some(ts) = get_remove_tags(matches) {
|
|
|
|
for t in ts {
|
2016-03-18 14:24:11 +00:00
|
|
|
if let Err(e) = entry.remove_tag(t) {
|
|
|
|
return Err(e);
|
|
|
|
}
|
2016-05-03 21:10:32 +00:00
|
|
|
}
|
2016-03-18 14:24:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|