summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-todo/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/domain/imag-todo/src/lib.rs')
-rw-r--r--bin/domain/imag-todo/src/lib.rs38
1 files changed, 21 insertions, 17 deletions
diff --git a/bin/domain/imag-todo/src/lib.rs b/bin/domain/imag-todo/src/lib.rs
index b2007b49..0f52a095 100644
--- a/bin/domain/imag-todo/src/lib.rs
+++ b/bin/domain/imag-todo/src/lib.rs
@@ -159,22 +159,14 @@ impl StatusMatcher {
}
pub fn is(mut self, s: Status) -> Self {
- self.add_is(s);
- self
- }
-
- pub fn add_is(&mut self, s: Status) {
self.is.push(s);
+ self
}
#[allow(clippy::wrong_self_convention)]
pub fn is_not(mut self, s: Status) -> Self {
- self.add_is_not(s);
- self
- }
-
- pub fn add_is_not(&mut self, s: Status) {
self.is_not.push(s);
+ self
}
pub fn matches(&self, todo: Status) -> bool {
@@ -182,10 +174,7 @@ impl StatusMatcher {
// On blacklist
false
} else {
- // No whitelist or on whitelist
- // or
- // Not on blacklist, but whitelist exists and not on it either
- self.is.is_empty() || self.is.iter().any(|t| *t == todo)
+ self.is.iter().any(|t| *t == todo)
}
}
}
@@ -372,15 +361,30 @@ fn list(rt: &Runtime) -> Result<()> {
let hidden = scmd.map(|s| s.is_present("list-hidden")).unwrap_or(false);
let done = scmd.map(|s| s.is_present("list-done")).unwrap_or(false);
let nopending = scmd.map(|s| s.is_present("list-nopending")).unwrap_or(true);
+ let deleted = scmd.map(|s| s.is_present("list-deleted")).unwrap_or(true);
trace!("table = {}", table);
trace!("hidden = {}", hidden);
trace!("done = {}", done);
trace!("nopending = {}", nopending);
- let mut matcher = StatusMatcher::new();
- if !done { matcher.add_is_not(Status::Done); }
- if nopending { matcher.add_is_not(Status::Pending); }
+ let matcher = {
+ let mut matcher = if nopending {
+ StatusMatcher::new().is_not(Status::Pending)
+ } else {
+ StatusMatcher::new().is(Status::Pending)
+ };
+
+ if done {
+ matcher = matcher.is(Status::Done)
+ }
+
+ if deleted {
+ matcher = matcher.is(Status::Deleted)
+ }
+
+ matcher
+ };
// TODO: Support printing as ASCII table
list_todos(rt, &matcher, hidden)