Compare commits
9 Commits
master
...
archive/li
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
617d377b01 | ||
|
|
c429b062cf | ||
|
|
a830f18dd5 | ||
|
|
56bd927747 | ||
|
|
8f92cb6f66 | ||
|
|
e6136e14b8 | ||
|
|
5605c4b1b9 | ||
|
|
c6467d90aa | ||
|
|
ddd3e9711b |
@@ -53,9 +53,28 @@ TODO: 2 prioritized (C).
|
||||
--
|
||||
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
|
||||
2 (A) notice the sunflowers
|
||||
TODO: 2 prioritized (A).
|
||||
TODO: 2 re-prioritized from (C) to (A).
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
@@ -66,25 +85,13 @@ TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh pri 2 a
|
||||
2 (A) notice the sunflowers
|
||||
TODO: 2 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: 2 already prioritized (A).
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
4 smell the coffee +wakeup
|
||||
3 stop
|
||||
--
|
||||
TODO: 4 of 4 tasks shown
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
95
tests/t1250-listpri.sh
Executable file
95
tests/t1250-listpri.sh
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='list priority functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
(B) smell the uppercase Roses +flowers @outside
|
||||
(C) notice the sunflowers
|
||||
stop
|
||||
EOF
|
||||
test_todo_session 'basic listpri' <<EOF
|
||||
>>> todo.sh listpri A
|
||||
--
|
||||
TODO: 0 of 3 tasks shown
|
||||
|
||||
>>> todo.sh -p listpri c
|
||||
2 (C) notice the sunflowers
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'listpri highlighting' <<EOF
|
||||
>>> todo.sh listpri
|
||||
[0;32m1 (B) smell the uppercase Roses +flowers @outside[0m
|
||||
[1;34m2 (C) notice the sunflowers[0m
|
||||
--
|
||||
TODO: 2 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
(B) smell the uppercase Roses +flowers @outside
|
||||
(C) notice the sunflowers
|
||||
(m)others will notice this
|
||||
(n) not a prioritized task
|
||||
notice the (C)opyright
|
||||
EOF
|
||||
test_todo_session 'listpri filtering priorities' <<EOF
|
||||
>>> todo.sh -p listpri
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
2 (C) notice the sunflowers
|
||||
--
|
||||
TODO: 2 of 5 tasks shown
|
||||
|
||||
>>> todo.sh -p listpri b
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
--
|
||||
TODO: 1 of 5 tasks shown
|
||||
|
||||
>>> todo.sh -p listpri c
|
||||
2 (C) notice the sunflowers
|
||||
--
|
||||
TODO: 1 of 5 tasks shown
|
||||
|
||||
>>> todo.sh -p listpri m
|
||||
--
|
||||
TODO: 0 of 5 tasks shown
|
||||
|
||||
>>> todo.sh -p listpri n
|
||||
--
|
||||
TODO: 0 of 5 tasks shown
|
||||
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
|
||||
@@ -81,6 +81,6 @@ test_todo_session 'fail multiple do attempts' <<EOF
|
||||
TODO: 3 marked as done.
|
||||
|
||||
>>> todo.sh -a do 3
|
||||
3 is already marked done
|
||||
TODO: 3 is already marked done.
|
||||
EOF
|
||||
test_done
|
||||
|
||||
@@ -68,4 +68,30 @@ TODO: 2 deprioritized.
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
(B) smell the uppercase Roses +flowers @outside
|
||||
(A) notice the sunflowers
|
||||
stop
|
||||
EOF
|
||||
test_todo_session 'depriority of unprioritized task' <<EOF
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh depri 3 2
|
||||
TODO: 3 is not prioritized.
|
||||
2 notice the sunflowers
|
||||
TODO: 2 deprioritized.
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
2 notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
66
todo.sh
66
todo.sh
@@ -58,7 +58,7 @@ shorthelp()
|
||||
listall|lsa [TERM...]
|
||||
listcon|lsc
|
||||
listfile|lf SRC [TERM...]
|
||||
listpri|lsp [PRIORITY]
|
||||
listpri|lsp [PRIORITY] [TERM...]
|
||||
listproj|lsprj
|
||||
move|mv ITEM# DEST [SRC]
|
||||
prepend|prep ITEM# "TEXT TO PREPEND"
|
||||
@@ -143,10 +143,11 @@ help()
|
||||
sorted by priority with line numbers. If TERM specified, lists
|
||||
all lines that contain TERM in SRC file.
|
||||
|
||||
listpri [PRIORITY]
|
||||
lsp [PRIORITY]
|
||||
listpri [PRIORITY] [TERM...]
|
||||
lsp [PRIORITY] [TERM...]
|
||||
Displays all tasks prioritized PRIORITY.
|
||||
If no PRIORITY specified, lists all prioritized tasks.
|
||||
If TERM specified, lists only prioritized tasks that contain TERM.
|
||||
|
||||
listproj
|
||||
lsprj
|
||||
@@ -324,8 +325,8 @@ replaceOrPrepend()
|
||||
cleaninput $input
|
||||
|
||||
# Retrieve existing priority and prepended date
|
||||
priority=$(sed -e "$item!d" -e $item's/^\(([A-Z]) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE")
|
||||
prepdate=$(sed -e "$item!d" -e $item's/^\(([A-Z]) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE")
|
||||
priority=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE")
|
||||
prepdate=$(sed -e "$item!d" -e $item's/^\((.) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE")
|
||||
|
||||
if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\}\)\{0,1\}.*/\1/')" ]; then
|
||||
# If the replaced text starts with a date, it will replace the existing
|
||||
@@ -921,10 +922,7 @@ case $action in
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "TODO: No task $item."
|
||||
|
||||
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
#it's all good, continue
|
||||
if sed "$item!d" "$TODO_FILE" | grep "^(.) " > /dev/null; then
|
||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
@@ -932,7 +930,7 @@ case $action in
|
||||
echo "TODO: $item deprioritized."
|
||||
fi
|
||||
else
|
||||
die "$errmsg"
|
||||
echo "TODO: $item is not prioritized."
|
||||
fi
|
||||
done
|
||||
;;
|
||||
@@ -964,7 +962,7 @@ case $action in
|
||||
echo "TODO: $item marked as done."
|
||||
fi
|
||||
else
|
||||
echo "$item is already marked done"
|
||||
echo "TODO: $item is already marked done."
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1012,22 +1010,11 @@ case $action in
|
||||
;;
|
||||
|
||||
"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:-}" ]
|
||||
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="[[:upper:]]"
|
||||
fi
|
||||
pri="($pri)"
|
||||
|
||||
_list "$TODO_FILE" "$pri"
|
||||
pri=$(printf "%s\n" "$1" | tr 'a-z' 'A-Z' | grep '^[A-Z]$') && shift || pri="[A-Z]"
|
||||
post_filter_command="grep '^ *[0-9]\+ (${pri}) '"
|
||||
_list "$TODO_FILE" "$@"
|
||||
;;
|
||||
|
||||
"move" | "mv" )
|
||||
@@ -1089,18 +1076,23 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
[[ "$newpri" = @([A-Z]) ]] || die "$errmsg"
|
||||
|
||||
sed -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" > /dev/null 2>&1
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
#it's all good, continue
|
||||
oldpri=$(sed -ne $item's/^(\(.\)) .*/\1/p' "$TODO_FILE")
|
||||
if [ "$oldpri" != "$newpri" ]; then
|
||||
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item $NEWTODO"
|
||||
echo "TODO: $item prioritized ($newpri)."
|
||||
fi
|
||||
else
|
||||
die "$errmsg"
|
||||
fi
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item $NEWTODO"
|
||||
if [ "$oldpri" != "$newpri" ]; then
|
||||
if [ "$oldpri" ]; then
|
||||
echo "TODO: $item re-prioritized from ($oldpri) to ($newpri)."
|
||||
else
|
||||
echo "TODO: $item prioritized ($newpri)."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ "$oldpri" = "$newpri" ]; then
|
||||
echo "TODO: $item already prioritized ($newpri)."
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user