feat(main): enable manual state updates

This commit is contained in:
xeruf 2024-07-29 11:15:13 +03:00
parent 8e7b8d3e66
commit 98d921b941
3 changed files with 25 additions and 12 deletions

View File

@ -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.

View File

@ -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());
}

View File

@ -302,7 +302,7 @@ impl Tasks {
});
}
fn set_state_for(&mut self, id: &EventId, comment: &str) -> Option<Event> {
pub(crate) fn set_state_for(&mut self, id: &EventId, comment: &str) -> Option<Event> {
let t = self.tasks.get_mut(id);
t.and_then(|task| {
task.set_state(