Allow passing multiple items to depri, like for the do command.
This commit is contained in:
@@ -6,7 +6,7 @@ test_description='basic depriority functionality
|
||||
|
||||
test_todo_session 'depriority usage' <<EOF
|
||||
>>> todo.sh depri B B
|
||||
usage: todo.sh depri ITEM#
|
||||
usage: todo.sh depri ITEM#[, ITEM#, ITEM#, ...]
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
@@ -41,4 +41,31 @@ TODO: 1 deprioritized.
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
(B) smell the uppercase Roses +flowers @outside
|
||||
(A) notice the sunflowers
|
||||
(C) stop
|
||||
EOF
|
||||
test_todo_session 'multiple depriority' <<EOF
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
3 (C) stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh depri 3 2
|
||||
3: stop
|
||||
TODO: 3 deprioritized.
|
||||
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
|
||||
|
||||
19
todo.sh
19
todo.sh
@@ -48,7 +48,7 @@ shorthelp()
|
||||
archive
|
||||
command [ACTIONS]
|
||||
del|rm NUMBER [TERM]
|
||||
dp|depri NUMBER
|
||||
dp|depri NUMBER[, NUMBER, NUMBER, ...]
|
||||
do NUMBER[, NUMBER, NUMBER, ...]
|
||||
help
|
||||
list|ls [TERM...]
|
||||
@@ -108,8 +108,8 @@ help()
|
||||
Deletes the item on line NUMBER in todo.txt.
|
||||
If term specified, deletes only the term from the line.
|
||||
|
||||
depri NUMBER
|
||||
dp NUMBER
|
||||
depri NUMBER[, NUMBER, NUMBER, ...]
|
||||
dp NUMBER[, NUMBER, NUMBER, ...]
|
||||
Deprioritizes (removes the priority) from the item
|
||||
on line NUMBER in todo.txt.
|
||||
|
||||
@@ -742,9 +742,13 @@ case $action in
|
||||
fi ;;
|
||||
|
||||
"depri" | "dp" )
|
||||
item=$2
|
||||
errmsg="usage: $TODO_SH depri ITEM#"
|
||||
errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]"
|
||||
shift;
|
||||
[ $# -eq 0 ] && die "$errmsg"
|
||||
|
||||
# Split multiple depri's, if comma separated change to whitespace separated
|
||||
# Loop the 'depri' function for each item
|
||||
for item in `echo $* | tr ',' ' '`; do
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
@@ -759,10 +763,11 @@ case $action in
|
||||
echo "`echo "$item: $NEWTODO"`"
|
||||
echo "TODO: $item deprioritized."
|
||||
}
|
||||
cleanup
|
||||
else
|
||||
die "$errmsg"
|
||||
fi;;
|
||||
fi
|
||||
done
|
||||
cleanup ;;
|
||||
|
||||
"do" )
|
||||
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
||||
|
||||
Reference in New Issue
Block a user