aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/vdir/calcurse-vdirsyncer
diff options
context:
space:
mode:
authorvxid <maxime.treca@gmail.com>2019-03-02 16:12:15 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2019-03-14 21:21:46 +0100
commitd26164fb725e22f8eebd8d94ad59cab3921b8a6f (patch)
treeb647b4588e2e71bf2260bc18eceeb2a0704c1d0f /contrib/vdir/calcurse-vdirsyncer
parent5eff08777b643c0e112921eb6cb78381361acb68 (diff)
downloadcalcurse-d26164fb725e22f8eebd8d94ad59cab3921b8a6f.tar.gz
calcurse-d26164fb725e22f8eebd8d94ad59cab3921b8a6f.zip
Add support for vdir synchronization
Add a script to synchronize calcurse with a VDIR collection. Add a wrapper script around vdirsyncer to automatically synchronize calcurse data to a vdirsyncer collection. Add script documentation and Makefile. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'contrib/vdir/calcurse-vdirsyncer')
-rwxr-xr-xcontrib/vdir/calcurse-vdirsyncer71
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/vdir/calcurse-vdirsyncer b/contrib/vdir/calcurse-vdirsyncer
new file mode 100755
index 0000000..c5371b5
--- /dev/null
+++ b/contrib/vdir/calcurse-vdirsyncer
@@ -0,0 +1,71 @@
+#!/bin/sh
+
+set -e
+
+usage() {
+ echo "usage: calcurse-vdirsyncer vdir [-h] [-f] [-v] [-D] datadir"
+ exit
+}
+
+set_vdir() {
+ if [ ! -d "$1" ]; then
+ echo "error: $1 is not a valid vdir directory."
+ exit 1
+ else
+ VDIR="$1"
+ fi
+}
+
+set_datadir() {
+ if [ -z "$1" ]; then
+ echo "error: no datadir specified."
+ usage
+ fi
+ if [ ! -d "$1" ]; then
+ echo "error: $1 is not a valid data directory."
+ exit 1
+ else
+ DATADIR="$1"
+ shift
+ fi
+}
+
+if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
+ usage
+fi
+
+DATADIR="$HOME/.calcurse"
+VERBOSE=""
+FORCE=""
+
+set_vdir "$1"
+shift
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -D|--datadir)
+ shift
+ set_datadir "$1"
+ shift
+ ;;
+ -h|--help)
+ usage
+ ;;
+ -f|--force)
+ FORCE="-f"
+ shift
+ ;;
+ -v|--verbose)
+ VERBOSE="-v"
+ shift
+ ;;
+ *)
+ echo "error: invalid argument $1"
+ usage
+ ;;
+ esac
+done
+
+calcurse-vdir export "$VDIR" -D "$DATADIR" "$FORCE" "$VERBOSE" && \
+ vdirsyncer sync && \
+ calcurse-vdir import "$VDIR" -D "$DATADIR" "$FORCE" "$VERBOSE"