Add OR and - support for tags (WIP)#456
Add OR and - support for tags (WIP)#456limdingwen wants to merge 3 commits intoGothenburgBitFactory:refactor/filteringfrom limdingwen:tag-operators
Conversation
Signed-off-by: Lim Ding Wen <limdingwen@gmail.com>
|
Just noticed from #358 that there are existing plans to implement Taskwarrior-like complex filters. That might conflict with this PR. |
Signed-off-by: Lim Ding Wen <limdingwen@gmail.com>
Signed-off-by: Lim Ding Wen <limdingwen@gmail.com>
|
Thanks @limdingwen for taking a stab at the problem! Looking at your PR and reading your analysis (especially point 2, the boolean parser) it came to my mind that we are maybe doing the right things at the wrong place. Let me explain:
Currently, this does not hurt much but it impedes improvements like the one you suggested. Ideally, we should be doing something like this when we query intervals (see below, what the functions So I would propose the following path to achieve the goal of more flexible tag filtering:
For the first I would add an abstract base class which defines the functions outlined above From this I would derive two classes
With that we can create the filter at the respective command and pass it to The next step would then be to create the real filter in the CLI where we have all the necessary information available and return it. This also means we have to change the current function I think then we are in the best position to implement a more flexible tag filtering... 🤔 |
|
Keep in mind also, one of the nice features of timewarrior is that tags are more general strings, this is a thing taskwarrior can't really do. So if we start using |
|
@smemsh Agreed, and thanks for the anecdote about "-tag" usage. While I'm not sure what would be a good way to do NOTs, I think ORs could be done as a sort of hint ( @lauft Thanks for the warm welcome! Honestly, most of that stuff is going over my head right now since I'm new to the codebase, so I'll leave it for the others to discuss. If that refactoring is going to take a long time to make, I think it would help others to add the OR/NOT functionality first, without the boolean parser, since that seems to be most of what was requested for now in the referenced issues. |
|
I might be biased, but long term I'd actually like the CLI syntax for |
|
Copying over the relevant part of the docs from taskwarrior, since for others who may be unfamiliar with it too:
@tbabej, sorry I'm new here so things may go over my head; are you proposing to move over the complex filter code from taskwarrior, when you said "get these features basically for free"? |
|
Hello @limdingwen, a small update from my side: I have pushed branch
Well, your implementation already contains a boolean parser, though a simple one. 😉 The important thing is that we now can do the parsing (and filter construction) at the right place: close to the CLI. Whether we can integrate it completely into the CLI (and how) is up to the implementation. I agree with @tbabej to align the CLI syntax, but we will have to address the issues addressed by @smemsh of using "or" as a tag, and having tags starting with Maybe quoting could help here: meaning matching all intervals not having tag Full support with parantheses will most likely require adaptions to parsing itself as one cannot simply add a |
Just thinking out loud, but I wonder if #363 could help here. Then we add additional hints to give the parser clues. For example, the following two lines could be equivalent: Which would make things like the following work: |
|
I have updated branch @limdingwen Do you think you can adapt your first version of the new tag filtering to this? Maybe at first only for Thinking about the new tag filtering: a feature flag may be appropriate here, so we do not surprise any user. |
|
@limdingwen I have done some thinking about the filtering, here are my findings so far: There are three classes of filters:
An Id filter excludes all other filters in the execution. If an id filter is used, only a range and/or a tag set are expected on the CLI. This does not mean a command cannot work with both, but it cannot use both at the same time (see I have compiled an overview what filters are used in the different commands in the following table (id means the command accepts only a single id, id+ meaning at least 2):
Most of the commands accept either and id filter or a tag and range filter - but there are some outliers:
|
|
Hi @lauft, for now I've simply copy-pasted my basic OR/- code (without boolean parsing) into Based on my understanding, this current version would not support boolean parsing yet due to Also -- apologies, I may have borked this PR :( Still new to GitHub forking, deleted my fork to somehow get the new branch into my repo, and now GitHub doesn't seem to detect changes in my New PR based on refactoring branch is here: #462 |

This WIP commit adds "OR" and "-" support to tags. For example:
Works with other commands like
timew dayas well, which is great. Several problems::or, so users may still use "OR" as a tag. Also for consistency. I need help with this since I'm not sure how to access the hints, or how to add a new hint. I think the-operator is good for negation, though it might cause problems if people try to create tags that start with-.timew summary lazy AND school OR workfor example, but that would requirefilter._tagsto be a vector instead to preserve ordering, which seems like a big change, so that's not in this commit.modify.t: timew modify should handle moving start times within an exclusion.(which states that you cannot overlap intervals) andstop.t: Add one interval that encloses an exclusion with day change(which gets a SIGABRT). Not sure how to solve this.Original comment on issue
Would close #209.
Would close #64.
Would close #358.