Add generic filtering mechanism #405
Draft
+1,303
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new filter flag
--filterto all evaluation commands, which accepts a generic filter query in the newly invented “klog filter language” format (KFL). E.g.:klog total --filter '2021-03-15 || #work'matches all entries that are either on2021-03-15or are tagged with#work.klog total --filter '2024-Q4 && (#work || #commute)'matches all entries of the fourth quarter of 2024 that either contain tags#workor#commute.klog total --filter '2022-01-15...2022-03-28'matches all entries from2022-01-15until2022-03-28(inclusive).The KFL is basically a more generic version of the CLI’s built-in filter flags (
--date,--tag,--period, etc.). While the built-in filter flags are AND’ed by default, KFL queries can combine the filter clauses with&&,||,!operators, and make use of grouping ((,)) with arbitrary nesting.Todos
2020...2021-Q3for all entries from the beginning of 2020 (2020-01-01) until the end of the third quarter of 2021 (2021-09-30).tokentype.service/querypackage and migrate to predicate mechanism.klog info --filtering).References
Related #190.