Compare commits
1 Commits
v2.8.0
...
archive/no
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faf86c88cb |
@@ -10,7 +10,8 @@ On failure, it will print each offending line number and line.
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_todo_session 'no old-style backtick command substitution' <<EOF
|
test_todo_session 'no old-style backtick command substitution' <<EOF
|
||||||
>>> sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/\`/{' -e '=;p' -e '}' "$(which todo.sh)"
|
>>> sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/\d96/{=;p}' "$(which todo.sh)"
|
||||||
EOF
|
EOF
|
||||||
|
# Note: Must encode backtick as \d96 to avoid error in the test framework.
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -53,25 +53,6 @@ TODO: 2 prioritized (C).
|
|||||||
--
|
--
|
||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add "smell the coffee +wakeup"
|
|
||||||
4 smell the coffee +wakeup
|
|
||||||
TODO: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
2 (C) notice the sunflowers
|
|
||||||
4 smell the coffee +wakeup
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 4 of 4 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(C) notice the sunflowers
|
|
||||||
stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'reprioritize' <<EOF
|
|
||||||
>>> todo.sh pri 2 A
|
>>> todo.sh pri 2 A
|
||||||
2 (A) notice the sunflowers
|
2 (A) notice the sunflowers
|
||||||
TODO: 2 re-prioritized from (C) to (A).
|
TODO: 2 re-prioritized from (C) to (A).
|
||||||
@@ -87,11 +68,23 @@ TODO: 3 of 3 tasks shown
|
|||||||
2 (A) notice the sunflowers
|
2 (A) notice the sunflowers
|
||||||
TODO: 2 already prioritized (A).
|
TODO: 2 already prioritized (A).
|
||||||
|
|
||||||
|
>>> todo.sh -p listpri
|
||||||
|
2 (A) notice the sunflowers
|
||||||
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
|
--
|
||||||
|
TODO: 2 of 3 tasks shown
|
||||||
|
|
||||||
|
>>> todo.sh add "smell the coffee +wakeup"
|
||||||
|
4 smell the coffee +wakeup
|
||||||
|
TODO: 4 added.
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
2 (A) notice the sunflowers
|
2 (A) notice the sunflowers
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
|
4 smell the coffee +wakeup
|
||||||
3 stop
|
3 stop
|
||||||
--
|
--
|
||||||
TODO: 3 of 3 tasks shown
|
TODO: 4 of 4 tasks shown
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ test_description='list priority functionality
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_todo_session 'listpri usage' <<EOF
|
||||||
|
>>> todo.sh listpri ?
|
||||||
|
usage: todo.sh listpri PRIORITY
|
||||||
|
note: PRIORITY must a single letter from A to Z.
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
cat > todo.txt <<EOF
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
(B) smell the uppercase Roses +flowers @outside
|
||||||
(C) notice the sunflowers
|
(C) notice the sunflowers
|
||||||
@@ -35,7 +42,7 @@ cat > todo.txt <<EOF
|
|||||||
(n) not a prioritized task
|
(n) not a prioritized task
|
||||||
notice the (C)opyright
|
notice the (C)opyright
|
||||||
EOF
|
EOF
|
||||||
test_todo_session 'listpri filtering priorities' <<EOF
|
test_todo_session 'listpri filtering' <<EOF
|
||||||
>>> todo.sh -p listpri
|
>>> todo.sh -p listpri
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
2 (C) notice the sunflowers
|
2 (C) notice the sunflowers
|
||||||
@@ -61,35 +68,4 @@ TODO: 0 of 5 tasks shown
|
|||||||
TODO: 0 of 5 tasks shown
|
TODO: 0 of 5 tasks shown
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) ccc xxx this line should be third.
|
|
||||||
ccc xxx this line should be third.
|
|
||||||
(A) aaa zzz this line should be first.
|
|
||||||
aaa zzz this line should be first.
|
|
||||||
(B) bbb yyy this line should be second.
|
|
||||||
bbb yyy this line should be second.
|
|
||||||
EOF
|
|
||||||
test_todo_session 'listpri filtering of TERM' <<EOF
|
|
||||||
>>> todo.sh -p listpri "should be"
|
|
||||||
3 (A) aaa zzz this line should be first.
|
|
||||||
5 (B) bbb yyy this line should be second.
|
|
||||||
1 (B) ccc xxx this line should be third.
|
|
||||||
--
|
|
||||||
TODO: 3 of 6 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -p listpri a "should be"
|
|
||||||
3 (A) aaa zzz this line should be first.
|
|
||||||
--
|
|
||||||
TODO: 1 of 6 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -p listpri b second
|
|
||||||
5 (B) bbb yyy this line should be second.
|
|
||||||
--
|
|
||||||
TODO: 1 of 6 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -p listpri x "should be"
|
|
||||||
--
|
|
||||||
TODO: 0 of 6 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
17
todo.sh
17
todo.sh
@@ -923,7 +923,7 @@ case $action in
|
|||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "TODO: No task $item."
|
[ -z "$todo" ] && die "TODO: No task $item."
|
||||||
|
|
||||||
if [[ "$todo" = \(?\)\ * ]]; then
|
if sed "$item!d" "$TODO_FILE" | grep "^(.) " > /dev/null; then
|
||||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
@@ -944,7 +944,7 @@ case $action in
|
|||||||
|
|
||||||
# Split multiple do's, if comma separated change to whitespace separated
|
# Split multiple do's, if comma separated change to whitespace separated
|
||||||
# Loop the 'do' function for each item
|
# Loop the 'do' function for each item
|
||||||
for item in $(echo $* | tr ',' ' '); do
|
for item in $(echo $* | tr ',' ' '); do
|
||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
@@ -1013,7 +1013,18 @@ 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 'a-z' 'A-Z' | grep '^[A-Z]$') && shift || pri="[A-Z]"
|
if [ "${1:-}" ]
|
||||||
|
then
|
||||||
|
## A priority was specified
|
||||||
|
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="[A-Z]"
|
||||||
|
fi
|
||||||
|
|
||||||
post_filter_command="grep '^ *[0-9]\+ (${pri}) '"
|
post_filter_command="grep '^ *[0-9]\+ (${pri}) '"
|
||||||
_list "$TODO_FILE" "$@"
|
_list "$TODO_FILE" "$@"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user