Add support for annotations

This matches the taskwarrior task model for annotations.
This commit is contained in:
Dustin J. Mitchell
2021-10-26 22:33:14 -04:00
parent 7fe5553093
commit 4314b8bc2d
8 changed files with 173 additions and 11 deletions

View File

@@ -39,6 +39,11 @@ pub(crate) fn execute<W: WriteColor>(
if let Some(wait) = task.get_wait() {
t.add_row(row![b->"Wait", wait]);
}
let mut annotations: Vec<_> = task.get_annotations().collect();
annotations.sort();
for ann in annotations {
t.add_row(row![b->"Annotation", format!("{}: {}", ann.entry, ann.description)]);
}
}
t.print(w)?;
}

View File

@@ -1,5 +1,6 @@
use crate::argparse::{DescriptionMod, Modification};
use taskchampion::TaskMut;
use chrono::Utc;
use taskchampion::{Annotation, TaskMut};
/// Apply the given modification
pub(super) fn apply_modification(
@@ -41,5 +42,12 @@ pub(super) fn apply_modification(
task.set_wait(wait)?;
}
if let Some(ref ann) = modification.annotate {
task.add_annotation(Annotation {
entry: Utc::now(),
description: ann.into(),
})?;
}
Ok(())
}