Add -S option to sort alphabetically
This commit is contained in:
parent
58bc83e53e
commit
269c28c4d3
42
t.sh
42
t.sh
|
@ -1103,14 +1103,43 @@ function addcmd() { # name usage description alt1|alt2|etc supportsall
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function getchildren() {
|
function sortuidlist() { # sort a list of task uids by task summng aries
|
||||||
|
local unsorted uidandsum withnl sorted_arr sorted unsorted_arr uid
|
||||||
|
unsorted="$1"
|
||||||
|
|
||||||
|
# change "123 456 789" to
|
||||||
|
# ("123#do something" "234#other task" "789#something#)
|
||||||
|
unsorted_arr=""
|
||||||
|
for uid in ${unsorted}; do
|
||||||
|
id=$(getid $uid)
|
||||||
|
unsorted_arr+=("${taskuid[$id]}#${tasksum[$id]}")
|
||||||
|
done
|
||||||
|
IFS=$'\n'
|
||||||
|
withnl=("${unsorted_arr[*]}")
|
||||||
|
sorted_arr=($(sort -df -t '#' -k2 <<<"${withnl[*]}"))
|
||||||
|
sorted=""
|
||||||
|
for uidandsum in ${sorted_arr[@]}; do
|
||||||
|
sorted="$sorted ${uidandsum%#*}"
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
echo "$sorted"
|
||||||
|
}
|
||||||
|
|
||||||
|
function getchildren() { # parentuid
|
||||||
local uid childuid children id
|
local uid childuid children id
|
||||||
uid=$1
|
uid=$1
|
||||||
children=""
|
children=""
|
||||||
for id in ${!taskid[@]}; do
|
for id in ${!taskid[@]}; do
|
||||||
[[ ${taskparent[$id]} == $uid ]] && children="$children ${taskuid[$id]}"
|
if [[ ${taskparent[$id]} == $uid ]]; then
|
||||||
|
children="$children ${taskuid[$id]}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
[[ -z $children ]] && return 1
|
[[ -z $children ]] && return 1
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $WANTSORT -eq 1 ]]; then
|
||||||
|
children=$(sortuidlist "$children")
|
||||||
|
fi
|
||||||
echo "$children"
|
echo "$children"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -1419,8 +1448,9 @@ DEBUG=0
|
||||||
TESTMODE=0
|
TESTMODE=0
|
||||||
AUTOSYNC=0
|
AUTOSYNC=0
|
||||||
CALID=$(cat "$confdir/defaultcal")
|
CALID=$(cat "$confdir/defaultcal")
|
||||||
|
WANTSORT=0
|
||||||
|
|
||||||
ARGS="fhic:dstyl:r:"
|
ARGS="fhic:dsStyl:r:"
|
||||||
while getopts "$ARGS" i; do
|
while getopts "$ARGS" i; do
|
||||||
case "$i" in
|
case "$i" in
|
||||||
h)
|
h)
|
||||||
|
@ -1446,6 +1476,9 @@ while getopts "$ARGS" i; do
|
||||||
s)
|
s)
|
||||||
AUTOSYNC=1
|
AUTOSYNC=1
|
||||||
;;
|
;;
|
||||||
|
S)
|
||||||
|
WANTSORT=1
|
||||||
|
;;
|
||||||
t)
|
t)
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
TESTMODE=1
|
TESTMODE=1
|
||||||
|
@ -1647,6 +1680,9 @@ else
|
||||||
uids="$uids ${taskuid[$id]}"
|
uids="$uids ${taskuid[$id]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [[ $WANTSORT -eq 1 ]]; then
|
||||||
|
uids=$(sortuidlist "$uids")
|
||||||
|
fi
|
||||||
if [[ ! $mode =~ $passive_modes ]]; then
|
if [[ ! $mode =~ $passive_modes ]]; then
|
||||||
info "About to run '$mode' on the following tasks:"
|
info "About to run '$mode' on the following tasks:"
|
||||||
needtitle=0
|
needtitle=0
|
||||||
|
|
Loading…
Reference in New Issue