From cae15ba7f56fe9d7af2bcf005c5d287d2fc57f6e Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Tue, 25 May 2021 21:41:48 +0200 Subject: Most calendar servers will yield the "primary" calendar as the first, so the existing logic (choose the first calendar if none were specified) usually makes sense. Degrading the error to a warning for when there are several calendars and none is explicitly given. --- calendar-cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/calendar-cli.py b/calendar-cli.py index bc445ba..76120a8 100755 --- a/calendar-cli.py +++ b/calendar-cli.py @@ -148,9 +148,10 @@ def find_calendar(caldav_conn, args): calendars = caldav.Principal(caldav_conn).calendars() if not calendars: sys.stderr.write("no calendar url given and no default calendar found - can't proceed. You will need to create a calendar first") + sys.exit(2) if len(calendars) > 1: - sys.stderr.write("no calendar url given and several calendars found - refusing to select one at random. You will need to specify which one to use") - return caldav.Principal(caldav_conn).calendars()[0] + sys.stderr.write("no calendar url given and several calendars found; assuming the primary is %s" % calendars[0].url) + return calendars[0] def _calendar_addics(caldav_conn, ics, uid, args): """" -- cgit v1.2.3