Support CLI syntax for changing tags

This commit is contained in:
Dustin J. Mitchell
2020-12-21 19:40:07 +00:00
parent 28c5fb2268
commit 54e8484bc2
4 changed files with 97 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
use crate::argparse::{DescriptionMod, Modification};
use failure::Fallible;
use std::convert::TryInto;
use taskchampion::TaskMut;
use termcolor::WriteColor;
@@ -32,6 +33,18 @@ pub(super) fn apply_modification<W: WriteColor>(
task.stop()?;
}
for tag in modification.add_tags.iter() {
// note that the parser should have already ensured that this tag was valid
let tag = tag.try_into()?;
task.add_tag(&tag)?;
}
for tag in modification.remove_tags.iter() {
// note that the parser should have already ensured that this tag was valid
let tag = tag.try_into()?;
task.remove_tag(&tag)?;
}
write!(w, "modified task {}\n", task.get_uuid())?;
Ok(())