use a generic Write instance for command output

This commit is contained in:
Dustin J. Mitchell
2020-12-20 19:45:24 -05:00
parent 6b550e7516
commit 7d17740ca8
13 changed files with 154 additions and 46 deletions

View File

@@ -1,9 +1,14 @@
use crate::argparse::{DescriptionMod, Modification};
use failure::Fallible;
use taskchampion::TaskMut;
use termcolor::WriteColor;
/// Apply the given modification
pub(super) fn apply_modification(task: &mut TaskMut, modification: &Modification) -> Fallible<()> {
pub(super) fn apply_modification<W: WriteColor>(
w: &mut W,
task: &mut TaskMut,
modification: &Modification,
) -> Fallible<()> {
match modification.description {
DescriptionMod::Set(ref description) => task.set_description(description.clone())?,
DescriptionMod::Prepend(ref description) => {
@@ -27,7 +32,7 @@ pub(super) fn apply_modification(task: &mut TaskMut, modification: &Modification
task.stop()?;
}
println!("modified task {}", task.get_uuid());
write!(w, "modified task {}\n", task.get_uuid())?;
Ok(())
}