forked from janek/mostr
feat: text notes as descriptions
This commit is contained in:
parent
daad3faddb
commit
0c90086833
3 changed files with 26 additions and 6 deletions
|
@ -32,9 +32,11 @@ TASK add syntax: `NAME: TAG1 TAG2`
|
|||
Dots can be repeated to move to parent tasks
|
||||
|
||||
- `:[IND][COL]` - add / remove property column COL to IND or end
|
||||
- `>` - Complete active task and move to parent
|
||||
- `<` - Close active task and move to parent
|
||||
- TBI: `-TEXT` - add text note (comment / description)
|
||||
- `>[TEXT]` - Complete active task and move to parent, with optional state description
|
||||
- `<[TEXT]` - Close active task and move to parent, with optional state description
|
||||
- `-TEXT` - add text note (comment / description)
|
||||
|
||||
State descriptions can be used for example for Kanban columns.
|
||||
|
||||
### Columns
|
||||
|
||||
|
|
|
@ -194,6 +194,10 @@ async fn main() {
|
|||
}
|
||||
},
|
||||
|
||||
Some('-') => {
|
||||
tasks.add_note(&input[1..])
|
||||
}
|
||||
|
||||
Some('>') | Some('<') => {
|
||||
tasks.update_state(&input[1..], |_| {
|
||||
Some(if op.unwrap() == '<' {
|
||||
|
|
20
src/tasks.rs
20
src/tasks.rs
|
@ -246,9 +246,23 @@ impl Tasks {
|
|||
where
|
||||
F: FnOnce(&Task) -> Option<State>,
|
||||
{
|
||||
self.position.and_then(|id| {
|
||||
self.update_state_for(&id, comment, f)
|
||||
})
|
||||
self.position
|
||||
.and_then(|id| self.update_state_for(&id, comment, f))
|
||||
}
|
||||
|
||||
pub(crate) fn add_note(&mut self, note: &str) {
|
||||
match self.position {
|
||||
None => eprintln!("Cannot add note '{}' without active task", note),
|
||||
Some(id) => {
|
||||
self.sender
|
||||
.submit(EventBuilder::text_note(note, vec![]))
|
||||
.map(|e| {
|
||||
self.tasks.get_mut(&id).map(|t| {
|
||||
t.props.insert(e.clone());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue