minor updates from review

This commit is contained in:
Dustin J. Mitchell 2021-06-01 09:23:36 -04:00
parent b18701c3cb
commit ac6b020b6d
3 changed files with 12 additions and 12 deletions

View file

@ -5,8 +5,8 @@ use nom::bytes::complete::tag as nomtag;
use nom::{branch::*, character::complete::*, combinator::*, sequence::*, IResult};
use taskchampion::Status;
/// Recognizes a colon-prefixed pair
fn colon_prefixed(prefix: &'static str) -> impl Fn(&str) -> IResult<&str, &str> {
/// Recognizes up to the colon of the common `<prefix>:...` syntax
fn colon_prefix(prefix: &'static str) -> impl Fn(&str) -> IResult<&str, &str> {
fn to_suffix<'a>(input: (&'a str, char, &'a str)) -> Result<&'a str, ()> {
Ok(input.2)
}
@ -28,7 +28,7 @@ pub(crate) fn status_colon(input: &str) -> IResult<&str, Status> {
_ => Err(()),
}
}
map_res(colon_prefixed("status"), to_status)(input)
map_res(colon_prefix("status"), to_status)(input)
}
/// Recognizes `wait:` to None and `wait:<ts>` to `Some(ts)`
@ -53,10 +53,10 @@ mod test {
use super::*;
#[test]
fn test_colon_prefixed() {
assert_eq!(colon_prefixed("foo")("foo:abc").unwrap().1, "abc");
assert_eq!(colon_prefixed("foo")("foo:").unwrap().1, "");
assert!(colon_prefixed("foo")("foo").is_err());
fn test_colon_prefix() {
assert_eq!(colon_prefix("foo")("foo:abc").unwrap().1, "abc");
assert_eq!(colon_prefix("foo")("foo:").unwrap().1, "");
assert!(colon_prefix("foo")("foo").is_err());
}
#[test]

View file

@ -154,9 +154,9 @@ impl Modification {
syntax: "wait:<timestamp>",
summary: "Set or unset the task's wait time",
description: "
Set the time before which the task is not actionable and
should not be shown in reports. With `wait:`, the time
is un-set. See the documentation for the timestamp syntax.",
Set the time before which the task is not actionable and should not be shown in
reports, e.g., `wait:3day` to wait for three days. With `wait:`, the time is
un-set. See the documentation for the timestamp syntax.",
});
}
}

View file

@ -36,8 +36,8 @@ pub(crate) fn execute<W: WriteColor>(
tags.sort();
t.add_row(row![b->"Tags", tags.join(" ")]);
}
if task.is_waiting() {
t.add_row(row![b->"Wait", task.get_wait().unwrap()]);
if let Some(wait) = task.get_wait() {
t.add_row(row![b->"Wait", wait]);
}
}
t.print(w)?;