Skip to content

Expose alarms and travel time in event output - #15

Merged
schappim merged 1 commit into
mainfrom
feature/expose-alarms-and-travel-time
Aug 30, 2026
Merged

Expose alarms and travel time in event output#15
schappim merged 1 commit into
mainfrom
feature/expose-alarms-and-travel-time

Conversation

@schappim

Copy link
Copy Markdown
Owner

Why

A user reported that ekctl calendar update doesn't update an event's notes. It turned out they were on v1.2.0, which has no update subcommand at all — but chasing it surfaced a real gap: --alarms and --travel-time are write-only. Nothing in the event JSON reflects either, so there's no way to confirm from the CLI that they applied.

hasAlarms looks like it serves that purpose but doesn't. Calendars apply a default alarm to new events, so a freshly created event reports hasAlarms: true with an alarm nobody asked for.

What

Adds alarms and travelTimeMinutes to the event dictionary, so they flow through show event, list events, add event, and update event in json, csv, and text.

Rendered in the same units the flags accept, so output round-trips into input:

"alarms": [
  { "type": "relative", "minutesBeforeStart": 10 },
  { "type": "relative", "minutesBeforeStart": -15 },
  { "type": "absolute", "date": "2026-02-15T08:00:00+11:00" }
],
"travelTimeMinutes": 20

--alarms "10" reads back as 10; --alarms "+15" as -15. Alarms created outside ekctl can be absolute, hence the type discriminator. Empty alarms render as [] and unset travel time as null, matching how attendees and location already behave.

Also: a latent crasher

Guarded both existing KVC writes to the undocumented travelTime property with responds(to:). KVC against a key the class doesn't define raises NSUnknownKeyException — an Objective-C exception Swift cannot catch — so if Apple ever drops the property, the existing unguarded setValue would hard-crash the CLI. Adding a read doubled that exposure. --travel-time now 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 20 reads back exactly; --alarms "+15,0,60" renders as -15, 0, 60.

Bumps to 1.6.0.

`--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.
@schappim
schappim merged commit 2540e7c into main Aug 30, 2026
1 check passed
@schappim
schappim deleted the feature/expose-alarms-and-travel-time branch August 30, 2026 23:08
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.

1 participant