diff --git a/t.sh b/t.sh index 04867a5..4603f0b 100755 --- a/t.sh +++ b/t.sh @@ -57,6 +57,7 @@ function usage() { format="%22s %-40s %s\n" echo "usage: $0 COMMAND [OPTIONS] [commandopts]" echo + echo " -c Select calendar to use (use '$0 showcals' to list)" echo " -f Assume 'yes' to all questions." echo " -l xx Specify name of local vdirsyncer storage name (default: $DEFAULT_VDS_LOCAL)" echo " -r xx Specify name of remote vdirsyncer storage name (default: $DEFAULT_VDS_REMOTE)" @@ -534,7 +535,7 @@ function move_right() { # move_right uid new_parent sed -i "/^RELATED-TO.*/d" "$file" sedrv=$? else - if grep -q ^RELATED-TO "$fil"e; then + if grep -q ^RELATED-TO "$file"; then sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" "$file" sedrv=$? else @@ -1400,9 +1401,6 @@ function getcalname() { # cal_name_or_number ###### - vdirsyncer name for your local calender [default cal_local] ###### - vdirsyncer name for your remote calender [default cal_remote] - - -VDIRSYNCER=/usr/local/bin/vdirsyncer DEFAULT_VDS_LOCAL=cal_local DEFAULT_VDS_REMOTE=cal_remote basedir=/Users/rpearce/code/task_cli @@ -1502,6 +1500,13 @@ while getopts "$ARGS" i; do done shift $((OPTIND - 1)) +# Make sure vdirsyncer is installed +if ! which -s vdirsyncer; then + error "Can't find ${BOLD}vdirsyncer${PLAIN}${RED} - please install it." + return 1 +fi +VDIRSYNCER=$(which vdirsyncer) + # validate CALID foundcal=$(getcalname "$CALID") if [[ -n $foundcal ]]; then @@ -1619,14 +1624,16 @@ elif [[ $mode == "left" ]]; then shift move_left $uid elif [[ $mode == "right" ]]; then - uid=$(getuid_witherror $1) - if [[ $2 == "-" ]]; then - puid="-" - else - puid=$(getuid_witherror $2 "parent task") + pid=$BASH_ARGV + if [[ $puid != "-" ]]; then + puid=$(getuid_witherror $pid "parent task") fi - shift 2 - move_right $uid $puid + + while [[ $# -gt 1 ]]; do + uid=$(getuid_witherror $1) + move_right $uid $puid + shift + done elif [[ $mode == "view" ]]; then uid=$(getuid_witherror $1) viewtask $uid