summaryrefslogtreecommitdiff
path: root/calendar-cli.py
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2021-05-25 21:41:48 +0200
committerTobias Brox <tobias@redpill-linpro.com>2021-05-25 21:41:48 +0200
commitcae15ba7f56fe9d7af2bcf005c5d287d2fc57f6e (patch)
tree1fc1fc8839ec550d805fd608e3db3e9384eb6696 /calendar-cli.py
parent753eb83e23abaf38b6df5a025b8b666c5b4071b3 (diff)
downloadcalendar-cli-cae15ba7f56fe9d7af2bcf005c5d287d2fc57f6e.zip
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.
Diffstat (limited to 'calendar-cli.py')
-rwxr-xr-xcalendar-cli.py5
1 files 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):
""""