diff --git a/add_date.sh b/add_date.sh index 430c076..507d6fe 100755 --- a/add_date.sh +++ b/add_date.sh @@ -74,15 +74,15 @@ BASEPATH=$(dirname $(realpath $0)) sed -i "s|replacemedescription|${3//$'\n'/\\\\n}|g" $ics # what we might need to replace, but not even that often: # dtstart, time component optional. We only work with minutes here: - [ -n $4 ] && sed -i "s|2300|$4|g" $ics + [ -n "$4" ] && echo ${#4} + [ -n "$4" ] && sed -i "s|2300|$4|g" $ics # dtend, same as dtstart: - [ -n $5 ] && sed -i "s|2359|$5|g" $ics + [ -n "$5" ] && sed -i "s|2359|$5|g" $ics # UUID: sed -i "s|99g999gggg|$UUID|g" $ics user=$username:$secret url=$domain/$username/$calendar -# curl -k --user $user -X PUT -H "Content-Type: text/calendar; charset=utf-8" --data-binary @./$ics --url $url/$ics -cat $ics + curl -k --user $user -X PUT -H "Content-Type: text/calendar; charset=utf-8" --data-binary @./$ics --url $url/$ics fi diff --git a/erinnermich.sh b/erinnermich.sh index e69de29..15c404d 100755 --- a/erinnermich.sh +++ b/erinnermich.sh @@ -0,0 +1,69 @@ +#! /bin/bash + +# This is a front-end to make the use of add_date.sh more convenient + +function usage { + echo "Usage: + $ $0 [-d |-P ] [-tstart ] [-tend ] + * MUST contain EXACTLY ONE of -frist, -wv or -termin + and can be expanded by e.g. -jura, -personal, ... + Expansion options need to be specified in in your .env first. + * values for -tstart and -tend are military time (HHMM) + * date can be any format that is recognised by the standard tool of the same name. + * EXACTLY ONE of -d and -P is REQUIRED. If both are given, it is not defined which will be passed on. + + $ $0 -help + Print this Message and exit" + exit 1 +} + +#Parsing Parameters: +BASEPATH=$(dirname $(realpath $0)) +. $BASEPATH/.env +unset $GETOPT_COMPATIBLE +ARGV=$(getopt -n "$0" -a -o "d:P:" -l "frist,wv,termin,$catopts,help,tstart:,tend:" -- "$@") +if [ $? -ne 0 ] +then + usage +fi +eval set -- "$ARGV" +CATEGORIES= +#Now we have $@ clean and tidy and begin parsing +while : +do + case "$1" in + "--help") usage ;; + "--frist") + CATEGORIES=FRIST,$CATEGORIES + shift ;; + "--termin") + CATEGORIES=TERMIN,$CATEGORIES + shift ;; + "--wv") + CATEGORIES=WV,$CATEGORIES + shift ;; + "--tstart") + tstart=$2 + shift ;; + "--tend") + tend=$2 + shift ;; + "--"?*) + CATEGORIES=$CATEGORIES$(tr 'a-z' 'A-Z' <<< ${1/--/}), + shift ;; + "-d") + date=$(date -d "$2" +%Y%m%d) + shift + shift ;; + "-P") + date=$(date -d "${${${${2/Y/ years}/m/ months}/W/ weeks}/D/ days}" +%Y%m%d) + shift + shift ;; + "--") + shift + break ;; + esac +done +#letztes Komma aus CATEGORIES streichen +CATEGORIES=${CATEGORIES/%,/} +$BASEPATH/add_date.sh $CATEGORIES $date $1 $tstart $tend; diff --git a/templates/template_frist.ics b/templates/template_frist.ics index ae4314b..cd2ba41 100644 --- a/templates/template_frist.ics +++ b/templates/template_frist.ics @@ -33,6 +33,8 @@ CATEGORIES:replacemecategory X-MOZ-GENERATION:1 replacemealarme END:VEVENT +END:VCALENDAR +BEGIN:VCALENDAR BEGIN:VTODO CREATED:20160224T172807Z LAST-MODIFIED:20160224T172807Z