minor updates from review
This commit is contained in:
@@ -5,8 +5,8 @@ use nom::bytes::complete::tag as nomtag;
|
|||||||
use nom::{branch::*, character::complete::*, combinator::*, sequence::*, IResult};
|
use nom::{branch::*, character::complete::*, combinator::*, sequence::*, IResult};
|
||||||
use taskchampion::Status;
|
use taskchampion::Status;
|
||||||
|
|
||||||
/// Recognizes a colon-prefixed pair
|
/// Recognizes up to the colon of the common `<prefix>:...` syntax
|
||||||
fn colon_prefixed(prefix: &'static str) -> impl Fn(&str) -> IResult<&str, &str> {
|
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, ()> {
|
fn to_suffix<'a>(input: (&'a str, char, &'a str)) -> Result<&'a str, ()> {
|
||||||
Ok(input.2)
|
Ok(input.2)
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ pub(crate) fn status_colon(input: &str) -> IResult<&str, Status> {
|
|||||||
_ => Err(()),
|
_ => 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)`
|
/// Recognizes `wait:` to None and `wait:<ts>` to `Some(ts)`
|
||||||
@@ -53,10 +53,10 @@ mod test {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_colon_prefixed() {
|
fn test_colon_prefix() {
|
||||||
assert_eq!(colon_prefixed("foo")("foo:abc").unwrap().1, "abc");
|
assert_eq!(colon_prefix("foo")("foo:abc").unwrap().1, "abc");
|
||||||
assert_eq!(colon_prefixed("foo")("foo:").unwrap().1, "");
|
assert_eq!(colon_prefix("foo")("foo:").unwrap().1, "");
|
||||||
assert!(colon_prefixed("foo")("foo").is_err());
|
assert!(colon_prefix("foo")("foo").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ impl Modification {
|
|||||||
syntax: "wait:<timestamp>",
|
syntax: "wait:<timestamp>",
|
||||||
summary: "Set or unset the task's wait time",
|
summary: "Set or unset the task's wait time",
|
||||||
description: "
|
description: "
|
||||||
Set the time before which the task is not actionable and
|
Set the time before which the task is not actionable and should not be shown in
|
||||||
should not be shown in reports. With `wait:`, the time
|
reports, e.g., `wait:3day` to wait for three days. With `wait:`, the time is
|
||||||
is un-set. See the documentation for the timestamp syntax.",
|
un-set. See the documentation for the timestamp syntax.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ pub(crate) fn execute<W: WriteColor>(
|
|||||||
tags.sort();
|
tags.sort();
|
||||||
t.add_row(row![b->"Tags", tags.join(" ")]);
|
t.add_row(row![b->"Tags", tags.join(" ")]);
|
||||||
}
|
}
|
||||||
if task.is_waiting() {
|
if let Some(wait) = task.get_wait() {
|
||||||
t.add_row(row![b->"Wait", task.get_wait().unwrap()]);
|
t.add_row(row![b->"Wait", wait]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.print(w)?;
|
t.print(w)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user