GothenburgBitFactory / taskchampion

Personal task-tracking library
MIT License
78 stars 20 forks source link

Filtering tasks - option to delegate task choice to fzf #104

Closed srfraser closed 5 months ago

srfraser commented 3 years ago

With a complex task selection or filter, it may be helpful to use an external tool such as fzf, allowing a familiar query structure and multi-select. We would then just accept the list of tasks the current operation applies to.

djmitche commented 3 years ago

It doesn't look like there are rust bindings for fzf. We could add such bindings (or reimplement it? it's in Go), or shell out to fzf if it's installed, but it feels weird to me to have a core feature depend on another binary.

djmitche commented 3 years ago

In fact, there's https://crates.io/crates/fuzzy-matcher which seems to implement something quite similar to fzf (but probably different in the heuristics).

So an interesting attribute of fuzzy searching is that it assigns scores -- so there may be "strong" and "weak" matches. I think that makes it a bad fit for TC's filters, since those just return a list of matched tasks. Instead, let's add a task find <pattern> which lists the matching tasks from most-matching to least-matching.

I often use something like task /seeds/ all to find a task I remember included "seeds" but that might be deleted or finished. With this issue, I could use ta find seeds. We could even "score" tasks based on their status, with active tasks > pending tasks > finished tasks > deleted tasks.

I think this would be a good-first-bug for someone who can take the time to understand the fuzzy_match crate and figure out how to integrate it.

dbr commented 3 years ago

There is https://github.com/lotabout/skim (a fzf re-implementation in Rust - oh which is the primary user of fuzzy-matcher), but I think the general approach is to use it as an external command. However I'm not totally clear how this would be implemented neatly into a Rust application (I've only seen fzf used in shell-script wrappers around third-party tools)

A ta find command does seem both useful and simple