Skip to content

Conversation

@jotaen
Copy link
Owner

@jotaen jotaen commented Dec 29, 2025

This PR adds a new filter flag --filter to 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 on 2021-03-15 or are tagged with #work.
  • klog total --filter '2024-Q4 && (#work || #commute)' matches all entries of the fourth quarter of 2024 that either contain tags #work or #commute.
  • klog total --filter '2022-01-15...2022-03-28' matches all entries from 2022-01-15 until 2022-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

  • Allow periods to appear in range clauses, e.g. 2020...2021-Q3 for all entries from the beginning of 2020 (2020-01-01) until the end of the third quarter of 2021 (2021-09-30).
  • Attach position and length info directly to token type.
  • For all parsing errors, ensure the error position and length is accurate.
  • Sunset legacy service/query package and migrate to predicate mechanism.
  • Write documentation (klog info --filtering).
  • Decide on terminology – ideas:
    • KFL = klog filter language (maybe that sounds a bit too “big” for what it is)
    • KFE = klog filter expression
    • KFQ = klog filter query

References

Related #190.

@jotaen jotaen changed the title Add generic filtering mechanism (klog filter language) Add generic filtering mechanism Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants