diff --git a/README.md b/README.md index 3260726..40bedf7 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,14 @@ Dots can be repeated to move to parent tasks - `:[IND][COL]` - add / remove property column COL to IND or end - `>[TEXT]` - Complete active task and move to parent, with optional state description - `<[TEXT]` - Close active task and move to parent, with optional state description -- `#TAG` - filter by tag -- `?TAG` - filter by state (type or description) +- `|TEXT` - Set state for current task from text (also aliased to `/` for now) - `-TEXT` - add text note (comment / description) +Property Filters: + +- `#TAG` - filter by tag +- `?TAG` - filter by state (type or description) - plain `?` to reset + State descriptions can be used for example for Kanban columns. An active tag or state filter will also create new tasks with those corresponding attributes. diff --git a/src/main.rs b/src/main.rs index 8a5990d..547acd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -249,17 +249,26 @@ async fn main() { Some('-') => tasks.add_note(arg), - Some('>') | Some('<') => { - tasks.update_state(arg, |_| { - Some(if op.unwrap() == '<' { - State::Closed - } else { - State::Done - }) - }); - tasks.move_up() + Some('>') => { + tasks.update_state(arg, |_| Some(State::Done)); + tasks.move_up(); } + Some('<') => { + tasks.update_state(arg, |_| Some(State::Closed)); + tasks.move_up(); + } + + Some('|') | Some('/') => match tasks.get_position() { + None => { + println!("First select a task to set its state!"); + } + Some(id) => { + tasks.set_state_for(&id, arg); + tasks.move_to(tasks.get_position()); + } + }, + Some('#') => { tasks.add_tag(arg.to_string()); } diff --git a/src/tasks.rs b/src/tasks.rs index 48c7a47..498aa3e 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -302,7 +302,7 @@ impl Tasks { }); } - fn set_state_for(&mut self, id: &EventId, comment: &str) -> Option { + pub(crate) fn set_state_for(&mut self, id: &EventId, comment: &str) -> Option { let t = self.tasks.get_mut(id); t.and_then(|task| { task.set_state(