Support ranges in task filter

This commit is contained in:
Rob Pearce 2021-11-21 17:44:48 +11:00
parent 163778e845
commit 3a18ea30cb
1 changed files with 22 additions and 4 deletions

26
t.sh
View File

@ -1630,8 +1630,17 @@ elif [[ $mode == "right" ]]; then
fi
while [[ $# -gt 1 ]]; do
uid=$(getuid_witherror $1)
move_right $uid $puid
if [[ $1 =~ ^[0-9]+-[0-9]+$ ]]; then
s=${1%-*}
e=${1#*-}
for ((w2=s; w2<=e; w2++)); do
uid=$(getuid_witherror $w2)
move_right $uid $puid
done
else
uid=$(getuid_witherror $1)
move_right $uid $puid
fi
shift
done
elif [[ $mode == "view" ]]; then
@ -1723,12 +1732,21 @@ else
exit 1
fi
fi
elif [[ $filter =~ ^[0-9\ ]+$ ]]; then
elif [[ $filter =~ ^[0-9\ \-]+$ ]]; then
# list of task IDs
for wantid in $filter; do
uids="$uids ${taskuid[$wantid]}"
if [[ $wantid =~ ^[0-9]+-[0-9]+$ ]]; then
s=${wantid%-*}
e=${wantid#*-}
for ((w2=s; w2<=e; w2++)); do
uids="$uids ${taskuid[$w2]}"
done
else
uids="$uids ${taskuid[$wantid]}"
fi
done
else
echo "GOT TEXT" >/dev/stderr
# text to match
a=$( echo ${filter} | tr 'A-Z' 'a-z')
for id in ${!taskid[@]}; do