-
Notifications
You must be signed in to change notification settings - Fork 213
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
Conversation
This includes support for interactive setting or editing an event.
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.
Looks good! Just a tiny typo. |
Typo. Co-authored-by: Hugo Barrera <[email protected]>
There was a problem hiding this 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.'), |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
khal/controllers.py
Outdated
@@ -413,6 +413,24 @@ def present_options(options, prefix="", sep=" ", width=70): | |||
return None | |||
|
|||
|
|||
def prompt_none(text, default=None, lower=False, type=None): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
khal/parse_datetime.py
Outdated
try: | ||
int(every) | ||
except ValueError: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isdigit() ftw :-)
There was a problem hiding this comment.
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.
Co-authored-by: Martin Stone <[email protected]>
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]>
Co-authored-by: Martin Stone <[email protected]>
This includes support for interactive setting or editing an event. Fixes #999