forked from janek/mostr
feat(tasks): option to fully set sorting
This commit is contained in:
parent
a7d02e60b2
commit
c83d8a2f55
|
@ -105,7 +105,7 @@ To stop time-tracking completely, simply move to the root of all tasks.
|
||||||
Dots and slashes can be repeated to move to parent tasks.
|
Dots and slashes can be repeated to move to parent tasks.
|
||||||
|
|
||||||
- `:[IND][PROP]` - add property column PROP at IND or end, if it already exists remove property column PROP or IND (1-indexed)
|
- `:[IND][PROP]` - add property column PROP at IND or end, if it already exists remove property column PROP or IND (1-indexed)
|
||||||
- `::[PROP]` - Sort by property PROP
|
- `::[PROP]` - Sort by property PROP (multiple space-separated values allowed)
|
||||||
- `([TIME]` - insert timetracking with the specified offset in minutes (empty: list tracked times)
|
- `([TIME]` - insert timetracking with the specified offset in minutes (empty: list tracked times)
|
||||||
- `)[TIME]` - stop timetracking with the specified offset in minutes - convenience helper to move to root (empty: stop now)
|
- `)[TIME]` - stop timetracking with the specified offset in minutes - convenience helper to move to root (empty: stop now)
|
||||||
- `>[TEXT]` - complete active task and move to parent, with optional state description
|
- `>[TEXT]` - complete active task and move to parent, with optional state description
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,5 +1,5 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, VecDeque};
|
||||||
use std::env::{args, var};
|
use std::env::{args, var};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -280,8 +280,13 @@ async fn main() {
|
||||||
Some(':') => {
|
Some(':') => {
|
||||||
let next = iter.next();
|
let next = iter.next();
|
||||||
if let Some(':') = next {
|
if let Some(':') = next {
|
||||||
// TODO reverse order if present
|
let str: String = iter.collect();
|
||||||
tasks.add_sorting_property(iter.collect())
|
let result = str.split_whitespace().map(|s| s.to_string()).collect::<VecDeque<_>>();
|
||||||
|
if result.len() == 1 {
|
||||||
|
tasks.add_sorting_property(str.trim().to_string())
|
||||||
|
} else {
|
||||||
|
tasks.set_sorting(result)
|
||||||
|
}
|
||||||
} else if let Some(digit) = next.and_then(|s| s.to_digit(10)) {
|
} else if let Some(digit) = next.and_then(|s| s.to_digit(10)) {
|
||||||
let index = (digit as usize).saturating_sub(1);
|
let index = (digit as usize).saturating_sub(1);
|
||||||
let remaining = iter.collect::<String>().trim().to_string();
|
let remaining = iter.collect::<String>().trim().to_string();
|
||||||
|
|
|
@ -792,7 +792,13 @@ impl Tasks {
|
||||||
&mut self.properties
|
&mut self.properties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_sorting(&mut self, vec: VecDeque<String>) {
|
||||||
|
self.sorting = vec;
|
||||||
|
info!("Now sorting by {:?}", self.sorting);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn add_sorting_property(&mut self, property: String) {
|
pub(crate) fn add_sorting_property(&mut self, property: String) {
|
||||||
|
// TODO reverse order if already present
|
||||||
self.sorting.push_front(property);
|
self.sorting.push_front(property);
|
||||||
self.sorting.truncate(4);
|
self.sorting.truncate(4);
|
||||||
info!("Now sorting by {:?}", self.sorting);
|
info!("Now sorting by {:?}", self.sorting);
|
||||||
|
|
Loading…
Reference in New Issue