commit c04ea6b1b6df63c352595972a4d579d891650ed0 parent a07f598305c3883fea271174c038f0dd07192985 Author: Oscar Benedito <oscar@oscarbenedito.com> Date: Wed, 19 Aug 2020 16:18:58 +0200 Add support for TODOs on DAVup Diffstat:
M | davup.sh | | | 27 | ++++++++++++++++++--------- |
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/davup.sh b/davup.sh @@ -35,14 +35,22 @@ get_card() { process_cal() { intro="BEGIN:VCALENDAR" - pre="BEGIN:VEVENT" - post="END:VEVENT" + preevent="BEGIN:VEVENT" + postevent="END:VEVENT" + pretodo="BEGIN:VTODO" + posttodo="END:VTODO" step="0" while read -r line; do + line="${line%}" case $step in - 0) echo "${line%}" | grep -q "${intro}" && step="1" && echo "${intro}" ;; - 1) echo "${line%}" && [ "${line%}" = "${post}" ] && step="2" ;; - 2) [ "${line%}" = "${pre}" ] && step="1" && echo "${line%}" ;; + 0) echo "${line}" | grep -q "${intro}" && step="1" && echo "${intro}" ;; + 1) echo "${line}"; \ + if [ "${line}" = "${preevent}" ]; then step="2"; \ + elif [ "${line}" = "${pretodo}" ]; then step="3"; fi ;; + 2) echo "${line}" && [ "${line}" = "${postevent}" ] && step="4" ;; + 3) echo "${line}" && [ "${line}" = "${posttodo}" ] && step="4" ;; + 4) if [ "${line}" = "${preevent}" ]; then step="2"; echo "${line}"; \ + elif [ "${line}" = "${pretodo}" ]; then step="3"; echo "${line}"; fi ;; esac done echo "END:VCALENDAR" @@ -53,14 +61,15 @@ process_card() { post="END:VCARD" step="1" while read -r line; do + line="${line%}" case $step in - 1) echo "${line%}" | grep -q "${pre}" && step="2" && echo "${pre}" ;; - 2) echo "${line%}" | grep -q "${post}" && step="1" && echo "${post}" \ - || echo "${line%}" ;; + 1) echo "${line}" | grep -q "${pre}" && step="2" && echo "${pre}" ;; + 2) echo "${line}" | grep -q "${post}" && step="1" && echo "${post}" \ + || echo "${line}" ;; esac done } # examples -resource="caldav/mycal" && get_cal | process_cal > calendar.ics +resource="caldav/mycal" && get_cal | process_cal > calendar_and_todos.ics resource="carddav/mycard" && get_card | process_card > contacts.vcf