feat(main): enable manual state updates
This commit is contained in:
parent
8e7b8d3e66
commit
98d921b941
|
@ -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.
|
||||
|
||||
|
|
27
src/main.rs
27
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());
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue