Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional shortcut flags for filtering by current week, month, etc. #140

Closed
JaPyR opened this issue Jan 25, 2022 · 10 comments · Fixed by #145
Closed

Additional shortcut flags for filtering by current week, month, etc. #140

JaPyR opened this issue Jan 25, 2022 · 10 comments · Fixed by #145
Labels
ENHANCEMENT Ideas and feature requests

Comments

@JaPyR
Copy link

JaPyR commented Jan 25, 2022

Hey, I think you it could be handy to have filter aliases similar to today and yesterday for weeks and months. Something like thisweek, lastweek, thismonth and lastmonth.

@jotaen
Copy link
Owner

jotaen commented Jan 25, 2022

Great idea!

I think all combinations of this and last, plus week, month, quarter and year should be possible.

Not sure what the best way would be for structuring the CLI flags then, because adding another 8 filter options might make the --help output pretty verbose. (Maybe there’d be a way for structuring it better, though.)

There is also one caveat about the week, because in some regions the week starts on a Sunday, and in others on a Monday.

@jotaen jotaen added the ENHANCEMENT Ideas and feature requests label Jan 25, 2022
@jotaen jotaen changed the title Additional aliases for week and month filters. Additional shortcut flags for filtering by current week, month, etc. Jan 25, 2022
@jotaen
Copy link
Owner

jotaen commented Jan 25, 2022

It might also be a nice addition to (optionally) extend the output of klog today then, so that it’s able to show like:

             Total
Today        3h41m
This week    6h55m
This month   12h2m
Other       22h12m
          ========
All         40h29m

Not sure that’s really needed, though, since you can also see this info in klog report (when using --aggregate).

@JaPyR
Copy link
Author

JaPyR commented Jan 26, 2022

There is also one caveat about the week, because in some regions the week starts on a Sunday, and in others on a Monday.

This was my initial though, but you are already providing possibility to aggregate by week so you have some assumptions/info when week start.

Not sure what the best way would be for structuring the CLI flags then, because adding another 8 filter options might make the --help output pretty verbose. (Maybe there’d be a way for structuring it better, though.)

For now output for --help isn't big and I don't see problem here. Alternatively instead of adding 8 flags it could be just 2 parameters (this and last) that would accept day, week, month, quarter and year.

It might also be a nice addition to (optionally) extend the output of klog today then, so that it’s able to show like:

To be honest most of the time I am using klog report :)

@jotaen
Copy link
Owner

jotaen commented Jan 26, 2022

you are already providing possibility to aggregate by week so you have some assumptions/info when week start.

Touché 😀 It would be good to solve this anyway (also for klog report then), the easiest I can think of is letting the week start default to Monday, and then letting users optionally set an environment variable like KLOG_WEEK_START=Sunday to override the behaviour.

Alternatively instead of adding 8 flags it could be just 2 parameters (this and last)

👍 I was having the same thought, but I’ll experiment with it a bit. Maybe the 8 flags are also fine, but I think it would be good to group all the filter flags differently then, just so that it’s easier to grasp for users.

@jotaen
Copy link
Owner

jotaen commented Jan 26, 2022

For the week start issue I’ve actually opened a separate ticket, because it’s a topic in itself.

@vladdeSV
Copy link
Contributor

(Just putting out how I use klog.)

Each month I report how much time I've spent with projects the previous, so I use the command:

klog tags --since 2021-10-01 --before 2021-11-01 time.2021.klg

If there was a way to specify a month more easily that would make me happy :)

@jotaen
Copy link
Owner

jotaen commented Jan 26, 2022

@vladdeSV for your use case, you could already use klog tags --period 2021-10 time.klg. The pattern for a period is either YYYY or YYYY-MM.

But nevertheless, klog tags --last-month time.klg (or whatever the flag will be) would be the easiest and most expressive.

@jotaen
Copy link
Owner

jotaen commented Jan 26, 2022

I should also document all these filters a bit better (note to self).

@vladdeSV
Copy link
Contributor

Ah! Didn't know about --period, which solves my use case :)

@jotaen
Copy link
Owner

jotaen commented Jan 29, 2022

I’ve been thinking about this a little, and I’d like it best to have individual boolean flags as in --this-week, --last-month, etc. (as opposed to just --this)

In order for the --help output not to become too convoluted, it would be good to divide all filters into “generic” ones, and into predefined shortcut filters, and then use the following notation for all the various --this-whatever variants:

Filter
  --tag=TAG,...      Records (or particular entries) that match this tag
  --date=DATE,...    Records at this date
  --since=DATE       Records since this date (inclusive)
  --until=DATE       Records until this date (inclusive)
  --after=DATE       Records after this date (exclusive)
  --before=DATE      Records before this date (exclusive)
  --period=PERIOD    Records in this period (YYYY-MM or YYYY)

Filter (shortcuts)
  --today        Records at today’s date
  --yesterday    Records at yesterday’s date
  --this-***     Records of the current week/quarter/month/year (e.g. --this-year)
  --last-***     Records of the previous week/quarter/month/year (e.g. --last-month)

That’s a bit unconventional, but I think it’s more pragmatic than having 8 separate lines with a repetitive structure.

In regards to the formatting, both --this-week and --thisweek etc. would be understood. (Although officially, it’d be with a dash.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ENHANCEMENT Ideas and feature requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants