ENH: Allow listpri filtering via TERM.

This even simplified the argument handling, since there can be no invalid priority any more; all other strings are taken as TERMs. And the check for empty ${1:-} was superfluous, anyway. Apart from these simplifications, it's basically just passing $@ to _list.
This commit is contained in:
Ingo Karkat
2011-05-10 15:54:50 +02:00
committed by Gina Trapani
parent b00ca1074a
commit f8b66f117a

26
todo.sh
View File

@@ -58,7 +58,7 @@ shorthelp()
listall|lsa [TERM...] listall|lsa [TERM...]
listcon|lsc listcon|lsc
listfile|lf SRC [TERM...] listfile|lf SRC [TERM...]
listpri|lsp [PRIORITY] listpri|lsp [PRIORITY] [TERM...]
listproj|lsprj listproj|lsprj
move|mv ITEM# DEST [SRC] move|mv ITEM# DEST [SRC]
prepend|prep ITEM# "TEXT TO PREPEND" prepend|prep ITEM# "TEXT TO PREPEND"
@@ -143,10 +143,11 @@ help()
sorted by priority with line numbers. If TERM specified, lists sorted by priority with line numbers. If TERM specified, lists
all lines that contain TERM in SRC file. all lines that contain TERM in SRC file.
listpri [PRIORITY] listpri [PRIORITY] [TERM...]
lsp [PRIORITY] lsp [PRIORITY] [TERM...]
Displays all tasks prioritized PRIORITY. Displays all tasks prioritized PRIORITY.
If no PRIORITY specified, lists all prioritized tasks. If no PRIORITY specified, lists all prioritized tasks.
If TERM specified, lists only prioritized tasks that contain TERM.
listproj listproj
lsprj lsprj
@@ -1013,22 +1014,11 @@ case $action in
;; ;;
"listpri" | "lsp" ) "listpri" | "lsp" )
shift ## was "listpri", new $1 is priority to list shift ## was "listpri", new $1 is priority to list or first TERM
if [ "${1:-}" ] pri=$(printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep '^[A-Z]$') && shift || pri="[A-Z]"
then post_filter_command="grep '^ *[0-9]\+ (${pri}) '"
## A priority was specified _list "$TODO_FILE" "$@"
pri=$( printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep '^[A-Z]$' ) || {
die "usage: $TODO_SH listpri PRIORITY
note: PRIORITY must a single letter from A to Z."
}
else
## No priority specified; show all priority tasks
pri="[[:upper:]]"
fi
pri="($pri)"
_list "$TODO_FILE" "$pri"
;; ;;
"move" | "mv" ) "move" | "mv" )