ENH: Allow concatenation of multiple priorities [-ranges] for listpri
It can be useful to filter for non-consecutive priority ranges. By enforcing uppercase in that added syntax, overlap with general TERM(s) (e.g. "foo-bar") can be mostly avoided (and in the rare case of having to filter by all-uppercase TERM(s) one can always pass the default A-Z filter, anyway).
This commit is contained in:
@@ -96,6 +96,26 @@ TODO: 0 of 5 tasks shown
|
|||||||
--
|
--
|
||||||
TODO: 1 of 5 tasks shown
|
TODO: 1 of 5 tasks shown
|
||||||
EOF
|
EOF
|
||||||
|
test_todo_session 'listpri filtering concatenation of priorities and -ranges' <<EOF
|
||||||
|
>>> todo.sh -p listpri CX
|
||||||
|
3 (C) notice the sunflowers
|
||||||
|
2 (X) clean the house from A-Z
|
||||||
|
4 (X) listen to music
|
||||||
|
--
|
||||||
|
TODO: 3 of 5 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh -p listpri ABR-Y
|
||||||
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
|
2 (X) clean the house from A-Z
|
||||||
|
4 (X) listen to music
|
||||||
|
--
|
||||||
|
TODO: 3 of 5 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh -p listpri A-
|
||||||
|
2 (X) clean the house from A-Z
|
||||||
|
--
|
||||||
|
TODO: 1 of 5 tasks shown
|
||||||
|
EOF
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
cat > todo.txt <<EOF
|
||||||
(B) ccc xxx this line should be third.
|
(B) ccc xxx this line should be third.
|
||||||
|
|||||||
6
todo.sh
6
todo.sh
@@ -254,7 +254,7 @@ actionsHelp()
|
|||||||
listpri [PRIORITIES] [TERM...]
|
listpri [PRIORITIES] [TERM...]
|
||||||
lsp [PRIORITIES] [TERM...]
|
lsp [PRIORITIES] [TERM...]
|
||||||
Displays all tasks prioritized PRIORITIES.
|
Displays all tasks prioritized PRIORITIES.
|
||||||
PRIORITIES can be a single one (A) or a range (A-C).
|
PRIORITIES can be a [concatenation of] single (A) or range (A-C).
|
||||||
If no PRIORITIES specified, lists all prioritized tasks.
|
If no PRIORITIES specified, lists all prioritized tasks.
|
||||||
If TERM specified, lists only prioritized tasks that contain TERM(s).
|
If TERM specified, lists only prioritized tasks that contain TERM(s).
|
||||||
Hides all tasks that contain TERM(s) preceded by a minus sign
|
Hides all tasks that contain TERM(s) preceded by a minus sign
|
||||||
@@ -1346,8 +1346,8 @@ case $action in
|
|||||||
"listpri" | "lsp" )
|
"listpri" | "lsp" )
|
||||||
shift ## was "listpri", new $1 is priority to list or first TERM
|
shift ## was "listpri", new $1 is priority to list or first TERM
|
||||||
|
|
||||||
pri=$(printf "%s\n" "$1" | tr '[:lower:]' '[:upper:]' | grep -e '^[A-Z]$' -e '^[A-Z]-[A-Z]$') && shift || pri="A-Z"
|
pri=$(printf "%s\n" "$1" | grep '^\([A-Za-z]\|[A-Za-z]-[A-Za-z]\|[A-Z][A-Z-]*[A-Z]\)$') && shift || pri="A-Z"
|
||||||
post_filter_command="${post_filter_command:-}${post_filter_command:+ | }grep '^ *[0-9]\+ ([${pri}]) '"
|
post_filter_command="${post_filter_command:-}${post_filter_command:+ | }grep '^ *[0-9]\+ ([${pri^^}]) '"
|
||||||
_list "$TODO_FILE" "$@"
|
_list "$TODO_FILE" "$@"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user