Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions fulcra_api/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,24 @@ def list_calendars(ctx):

@cli.command("calendar-events", short_help="Return Apple calendar events")
@time_range
@click.option(
"--calendar-name", type=str, default=None, help="Return events matching calendar name."
)
@click.pass_context
@requires_auth
def list_calendar_events(ctx, start_time: datetime, end_time: datetime):
def list_calendar_events(ctx, calendar_name: str | None, start_time: datetime, end_time: datetime):
"""Return Apple Calendar Event records across TIME_RANGE.

TIME_RANGE: Two start & end date arguments in ISO8601 format or a single interval argument relative to the current time ("1 week", "2 days", "3h", etc.)
"""

try:
results = ctx.obj.calendar_events(start_time, end_time)
calendar_ids = None
if calendar_name is not None:
calendars = [c for c in ctx.obj.calendars() if c["calendar_name"].lower() == calendar_name.lower()]
calendar_ids = [c["calendar_id"] for c in calendars]

results = ctx.obj.calendar_events(start_time, end_time, calendar_ids=calendar_ids)
except HTTPError as exc:
raise click.ClickException(exc)

Expand Down