Expose alarms and travel time in event output - #15
Merged
Conversation
`--alarms` and `--travel-time` were write-only: nothing in the event JSON reflected them, so there was no way to confirm from the CLI that either flag had taken effect. `hasAlarms` looked like it served that purpose but doesn't — calendars apply a default alarm to new events, so it reports true even for an event whose alarms you never touched. Add `alarms` and `travelTimeMinutes` to the event dictionary, which carries them through show/list/add/update in all three output formats. Both render in the same units the flags accept, so output round-trips back into input: a relative alarm 10 minutes before the start reads `minutesBeforeStart: 10`, matching `--alarms "10"`, and one 15 minutes after reads -15, matching `--alarms "+15"`. Alarms created outside ekctl may be absolute rather than relative, hence the `type` discriminator. Guard both KVC writes to the undocumented `travelTime` property while we're here. KVC against a key the class doesn't define raises NSUnknownKeyException, which Swift cannot catch, so if a future macOS drops the property the existing unguarded `setValue` would hard-crash the CLI. Adding the read doubled that exposure. `--travel-time` now returns an error instead. Bump to 1.6.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
A user reported that
ekctl calendar updatedoesn't update an event's notes. It turned out they were on v1.2.0, which has noupdatesubcommand at all — but chasing it surfaced a real gap:--alarmsand--travel-timeare write-only. Nothing in the event JSON reflects either, so there's no way to confirm from the CLI that they applied.hasAlarmslooks like it serves that purpose but doesn't. Calendars apply a default alarm to new events, so a freshly created event reportshasAlarms: truewith an alarm nobody asked for.What
Adds
alarmsandtravelTimeMinutesto the event dictionary, so they flow throughshow event,list events,add event, andupdate eventin json, csv, and text.Rendered in the same units the flags accept, so output round-trips into input:
--alarms "10"reads back as10;--alarms "+15"as-15. Alarms created outside ekctl can be absolute, hence thetypediscriminator. Empty alarms render as[]and unset travel time asnull, matching howattendeesandlocationalready behave.Also: a latent crasher
Guarded both existing KVC writes to the undocumented
travelTimeproperty withresponds(to:). KVC against a key the class doesn't define raisesNSUnknownKeyException— an Objective-C exception Swift cannot catch — so if Apple ever drops the property, the existing unguardedsetValuewould hard-crash the CLI. Adding a read doubled that exposure.--travel-timenow returns a clear error instead.Testing
9 new unit tests (146 total, all passing): before/after/at-start offsets, absolute alarms, nil and empty, sub-minute offsets rounding rather than truncating, and a round-trip test asserting
AlarmParsing.parse→ render returns the original flag value.Verified live against real calendars (created and deleted):
--alarms "10,30" --travel-time 20reads back exactly;--alarms "+15,0,60"renders as-15, 0, 60.Bumps to 1.6.0.