forked from janek/mostr
feat: hashtag list and quick filter override
This commit is contained in:
parent
08b0ba48a3
commit
6b7b6b91a8
4 changed files with 30 additions and 4 deletions
|
@ -110,8 +110,9 @@ Dots can be repeated to move to parent tasks.
|
||||||
|
|
||||||
Property Filters:
|
Property Filters:
|
||||||
|
|
||||||
- `+TAG` - filter by tag
|
- `#TAG` - set tag filter (empty: list all used tags)
|
||||||
- `-TAG` - remove filter by tag
|
- `+TAG` - add tag filter
|
||||||
|
- `-TAG` - remove tag filters
|
||||||
- `?STATE` - filter by state (type or description) - plain `?` to reset
|
- `?STATE` - filter by state (type or description) - plain `?` to reset
|
||||||
|
|
||||||
State descriptions can be used for example for Kanban columns or review flows.
|
State descriptions can be used for example for Kanban columns or review flows.
|
||||||
|
|
|
@ -58,6 +58,6 @@ fn format_tag(tag: &Tag) -> String {
|
||||||
|
|
||||||
pub(crate) fn is_hashtag(tag: &Tag) -> bool {
|
pub(crate) fn is_hashtag(tag: &Tag) -> bool {
|
||||||
tag.single_letter_tag()
|
tag.single_letter_tag()
|
||||||
.is_some_and(|sltag| sltag.character == Alphabet::T)
|
.is_some_and(|letter| letter.character == Alphabet::T)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -331,7 +331,17 @@ async fn main() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Some('#') | Some('+') => {
|
Some('#') => {
|
||||||
|
match arg {
|
||||||
|
Some(arg) => tasks.set_tag(arg.to_string()),
|
||||||
|
None => {
|
||||||
|
println!("Hashtags of all known tasks:\n{}", tasks.all_hashtags().join(" "));
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Some('+') => {
|
||||||
match arg {
|
match arg {
|
||||||
Some(arg) => tasks.add_tag(arg.to_string()),
|
Some(arg) => tasks.add_tag(arg.to_string()),
|
||||||
None => tasks.clear_filter()
|
None => tasks.clear_filter()
|
||||||
|
|
15
src/tasks.rs
15
src/tasks.rs
|
@ -102,6 +102,16 @@ impl Tasks {
|
||||||
|
|
||||||
children
|
children
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn all_hashtags(&self) -> impl Iterator<Item=&str> {
|
||||||
|
self.tasks.values()
|
||||||
|
.filter(|t| t.pure_state() != State::Closed)
|
||||||
|
.filter_map(|t| t.tags.as_ref()).flatten()
|
||||||
|
.filter(|tag| is_hashtag(tag))
|
||||||
|
.filter_map(|tag| tag.content().map(|s| s.trim()))
|
||||||
|
.sorted_unstable()
|
||||||
|
.dedup()
|
||||||
|
}
|
||||||
|
|
||||||
/// Total time in seconds tracked on this task by the current user.
|
/// Total time in seconds tracked on this task by the current user.
|
||||||
pub(crate) fn time_tracked(&self, id: EventId) -> u64 {
|
pub(crate) fn time_tracked(&self, id: EventId) -> u64 {
|
||||||
|
@ -350,6 +360,11 @@ impl Tasks {
|
||||||
info!("Removed all filters");
|
info!("Removed all filters");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_tag(&mut self, tag: String) {
|
||||||
|
self.tags.clear();
|
||||||
|
self.add_tag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn add_tag(&mut self, tag: String) {
|
pub(crate) fn add_tag(&mut self, tag: String) {
|
||||||
self.view.clear();
|
self.view.clear();
|
||||||
info!("Added tag filter for #{tag}");
|
info!("Added tag filter for #{tag}");
|
||||||
|
|
Loading…
Add table
Reference in a new issue