insanum / gcalcli

Google Calendar Command Line Interface
MIT License
3.31k stars 311 forks source link

calendars with spaces in them cause an error #637

Closed sweth closed 1 month ago

sweth commented 2 years ago

The CLI arg to specify a calendar appears to be misparsed and treated as a start time if the calendar name contains a space. I've tried every variation I can think of to escape the space (after the necessary quoting for the shell) but nothing seems to work.

$ (gcalcli --config-folder ~/etc/gcalcli list | grep gcal ; for CAL in gcalcli-test "gcalcli test" ; do echo "$CAL"
; gcalcli --config-folder ~/etc/gcalcli agenda --calendar="$CAL" ; done)
  owner  gcalcli test
  owner  gcalcli-test
gcalcli-test

No Events Found...
gcalcli test
usage: gcalcli agenda [-h]
                      [--details {calendar,location,length,reminders,description,url,attendees,email,attachments,end,all}]
                      [--color-owner COLOR_OWNER] [--color-writer COLOR_WRITER] [--color-reader COLOR_READER]
                      [--color-freebusy COLOR_FREEBUSY] [--color-date COLOR_DATE] [--color-now-marker COLOR_NOW_MARKER]
                      [--color-border COLOR_BORDER] [--color-title COLOR_TITLE] [--tsv] [--nostarted] [--nodeclined]
                      [--width CAL_WIDTH] [--military] [--no-military] [--override-color]
                      [start] [end]
gcalcli agenda: error: argument start: invalid get_time_from_str value: '--calendar=gcalcli test'
conceptrat commented 1 year ago

I believe you have the "--calendar" option in the wrong position. You can see this from the error where it says "...invalid get_time_from_str value: '--calendar=gcalcli test'". Notice that the error references the complete string '--calendar=gcalcli test' because you're effectively passing that whole string as the start timestamp. I made this same mistake a couple of times while typing out commands. It should be before the sub-command "agenda" like this "gcalcli --calendar="$CAL" agenda...". So what you should have is:

(gcalcli --config-folder ~/etc/gcalcli list | grep gcal ; for CAL in gcalcli-test "gcalcli test" ; do echo "$CAL" ; gcalcli --config-folder ~/etc/gcalcli --calendar="$CAL" agenda ; done)

Hope this clears things up 👍

dbarnett commented 1 month ago

I merged #698 as a quick fix to make the error more self-diagnosing, and filed #697 to consider making the order-dependent parsing for --calendar more robust.