Skip to content

Add --every / -e option to the new command #1052

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

Closed
wants to merge 24 commits into from
Closed

Add --every / -e option to the new command #1052

wants to merge 24 commits into from

Conversation

ghost
Copy link

@ghost ghost commented May 26, 2021

This includes support for interactive setting or editing an event. Fixes #999

Hugo Osvaldo Barrera and others added 2 commits May 26, 2021 10:15
This includes support for interactive setting or
editing an event.
Hugo Barrera and others added 4 commits May 26, 2021 17:20
Update IRC references to Libera.Chat
Typo

Co-authored-by: Hugo Barrera <[email protected]>
Typo

Co-authored-by: Hugo Barrera <[email protected]>
Fix #999.

This also addresses a defect where editing a previously saved event
cause the 3 rrule properties (freq, until and interval) to have
incorrect default type (list instead of str), and freq value is forced
to lower case as the current code requires it but more important that is
how the values are presented in the interactive session.
@WhyNotHugo
Copy link
Member

Looks good! Just a tiny typo.

Typo.

Co-authored-by: Hugo Barrera <[email protected]>
Copy link
Collaborator

@d7415 d7415 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few things here. It could probably also do with a test.

I'm open to opinions, but I also think we should probably add this to ikhal at the same time to prevent events created in khal that can't be fully edited in ikhal.

khal/cli.py Outdated
@@ -341,6 +341,9 @@ def klist(ctx, include_calendar, exclude_calendar,
help=('Repeat event: daily, weekly, monthly or yearly.'))
@click.option('--until', '-u',
help=('Stop an event repeating on this date.'))
@click.option('--every', '-e',
help=('Frequency for repeating events.'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Referring to this as "frequency" is likely to cause confusion as that's used in the code and the RFC for "weekly"/etc (FREQ)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree, tried a few things different variations to make precise and concise and mixed it up in the final edit. The wording from the spec would be "positive integer representing at which intervals the recurrence rule repeats". "interval of repeating event"?

Copy link
Author

@ghost ghost May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially looked at adding/updating tests but found some that were relevant were marked xfail so I was not sure how to proceed.

@@ -413,6 +413,24 @@ def present_options(options, prefix="", sep=" ", width=70):
return None


def prompt_none(text, default=None, lower=False, type=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "helper" feels like it's overcomplicating things to me. Especially with the two optional arguments that are only used once each - i.e. it's called 3 times, with 2 special cases.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the helper to eliminate the duplicate logic for the 3 attributes. This shrunk the code from 14 to 7 lines not counting the helper. Planning on using it to fix #1054 which would make it the 4th use, and it's duplicated against for the "else" attribute case and alarm (6 uses).

No love lost on the lower case conversion special case either, but it needs to happen after the type coercing from list to str. The better alternative is probably to split the function into two: 1. convert value, if list, to str. Any idea of name for this function? 2. "None" business then handle the case conversion for frequency inline.

In either case, I was looking for input on #1050 to see if we can eliminate the magic "None" value, so this just leaves the type conversion.

Comment on lines 423 to 425
try:
int(every)
except ValueError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be clearer here (and more efficient, not that it really matters) to use if every.isdigit() here, as you're not using the cast.

Copy link
Author

@ghost ghost May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, later discovered that prompt had a type feature to constraint the input which is a better way of handling it, and later learned that it also have to be positive to I will have a change on that coming.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw .isdigit() would return false for negatives :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isdigit() ftw :-)

Copy link
Author

@ghost ghost May 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, turns out that stores values are type vInt so cannot use isdigit() on that, and I need to check for int(every) > 0. Just a heads up if you wonder why I didn't end up usign isdigit() after all.

allanwind and others added 17 commits May 27, 2021 10:15
Co-authored-by: Martin Stone <[email protected]>
Co-authored-by: Martin Stone <[email protected]>
This includes support for interactive setting or
editing an event.
Typo

Co-authored-by: Hugo Barrera <[email protected]>
Typo

Co-authored-by: Hugo Barrera <[email protected]>
Fix #999.

This also addresses a defect where editing a previously saved event
cause the 3 rrule properties (freq, until and interval) to have
incorrect default type (list instead of str), and freq value is forced
to lower case as the current code requires it but more important that is
how the values are presented in the interactive session.
Typo.

Co-authored-by: Hugo Barrera <[email protected]>
Co-authored-by: Martin Stone <[email protected]>
Co-authored-by: Martin Stone <[email protected]>
@ghost ghost closed this by deleting the head repository Sep 13, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

custom recurrence support for the CLI
4 participants