Add usage() item for -c option.

This commit is contained in:
Rob Pearce 2021-11-21 10:54:25 +11:00
parent 575d29d2cb
commit 163778e845
1 changed files with 18 additions and 11 deletions

27
t.sh
View File

@ -57,6 +57,7 @@ function usage() {
format="%22s %-40s %s\n" format="%22s %-40s %s\n"
echo "usage: $0 COMMAND [OPTIONS] [commandopts]" echo "usage: $0 COMMAND [OPTIONS] [commandopts]"
echo echo
echo " -c Select calendar to use (use '$0 showcals' to list)"
echo " -f Assume 'yes' to all questions." echo " -f Assume 'yes' to all questions."
echo " -l xx Specify name of local vdirsyncer storage name (default: $DEFAULT_VDS_LOCAL)" 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)" 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" sed -i "/^RELATED-TO.*/d" "$file"
sedrv=$? sedrv=$?
else 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" sed -i "s/^RELATED-TO.*/RELATED-TO;RELTYPE=PARENT:${taskparent[$id]}/" "$file"
sedrv=$? sedrv=$?
else else
@ -1400,9 +1401,6 @@ function getcalname() { # cal_name_or_number
###### - vdirsyncer name for your local calender [default cal_local] ###### - vdirsyncer name for your local calender [default cal_local]
###### - vdirsyncer name for your remote calender [default cal_remote] ###### - vdirsyncer name for your remote calender [default cal_remote]
VDIRSYNCER=/usr/local/bin/vdirsyncer
DEFAULT_VDS_LOCAL=cal_local DEFAULT_VDS_LOCAL=cal_local
DEFAULT_VDS_REMOTE=cal_remote DEFAULT_VDS_REMOTE=cal_remote
basedir=/Users/rpearce/code/task_cli basedir=/Users/rpearce/code/task_cli
@ -1502,6 +1500,13 @@ while getopts "$ARGS" i; do
done done
shift $((OPTIND - 1)) 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 # validate CALID
foundcal=$(getcalname "$CALID") foundcal=$(getcalname "$CALID")
if [[ -n $foundcal ]]; then if [[ -n $foundcal ]]; then
@ -1619,14 +1624,16 @@ elif [[ $mode == "left" ]]; then
shift shift
move_left $uid move_left $uid
elif [[ $mode == "right" ]]; then elif [[ $mode == "right" ]]; then
uid=$(getuid_witherror $1) pid=$BASH_ARGV
if [[ $2 == "-" ]]; then if [[ $puid != "-" ]]; then
puid="-" puid=$(getuid_witherror $pid "parent task")
else
puid=$(getuid_witherror $2 "parent task")
fi fi
shift 2
while [[ $# -gt 1 ]]; do
uid=$(getuid_witherror $1)
move_right $uid $puid move_right $uid $puid
shift
done
elif [[ $mode == "view" ]]; then elif [[ $mode == "view" ]]; then
uid=$(getuid_witherror $1) uid=$(getuid_witherror $1)
viewtask $uid viewtask $uid