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
|
test_todo_session 'depriority usage' <<EOF
|
||||||
>>> todo.sh depri B B
|
>>> todo.sh depri B B
|
||||||
usage: todo.sh depri ITEM#
|
usage: todo.sh depri ITEM#[, ITEM#, ITEM#, ...]
|
||||||
=== 1
|
=== 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -41,4 +41,31 @@ TODO: 1 deprioritized.
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
EOF
|
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
|
test_done
|
||||||
|
|||||||
47
todo.sh
47
todo.sh
@@ -48,7 +48,7 @@ shorthelp()
|
|||||||
archive
|
archive
|
||||||
command [ACTIONS]
|
command [ACTIONS]
|
||||||
del|rm NUMBER [TERM]
|
del|rm NUMBER [TERM]
|
||||||
dp|depri NUMBER
|
dp|depri NUMBER[, NUMBER, NUMBER, ...]
|
||||||
do NUMBER[, NUMBER, NUMBER, ...]
|
do NUMBER[, NUMBER, NUMBER, ...]
|
||||||
help
|
help
|
||||||
list|ls [TERM...]
|
list|ls [TERM...]
|
||||||
@@ -108,8 +108,8 @@ help()
|
|||||||
Deletes the item on line NUMBER in todo.txt.
|
Deletes the item on line NUMBER in todo.txt.
|
||||||
If term specified, deletes only the term from the line.
|
If term specified, deletes only the term from the line.
|
||||||
|
|
||||||
depri NUMBER
|
depri NUMBER[, NUMBER, NUMBER, ...]
|
||||||
dp NUMBER
|
dp NUMBER[, NUMBER, NUMBER, ...]
|
||||||
Deprioritizes (removes the priority) from the item
|
Deprioritizes (removes the priority) from the item
|
||||||
on line NUMBER in todo.txt.
|
on line NUMBER in todo.txt.
|
||||||
|
|
||||||
@@ -742,27 +742,32 @@ case $action in
|
|||||||
fi ;;
|
fi ;;
|
||||||
|
|
||||||
"depri" | "dp" )
|
"depri" | "dp" )
|
||||||
item=$2
|
errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]"
|
||||||
errmsg="usage: $TODO_SH depri ITEM#"
|
shift;
|
||||||
|
[ $# -eq 0 ] && die "$errmsg"
|
||||||
|
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
# Split multiple depri's, if comma separated change to whitespace separated
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
# Loop the 'depri' function for each item
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
for item in `echo $* | tr ',' ' '`; do
|
||||||
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
||||||
|
|
||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
#it's all good, continue
|
#it's all good, continue
|
||||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "`echo "$item: $NEWTODO"`"
|
echo "`echo "$item: $NEWTODO"`"
|
||||||
echo "TODO: $item deprioritized."
|
echo "TODO: $item deprioritized."
|
||||||
}
|
}
|
||||||
cleanup
|
else
|
||||||
else
|
die "$errmsg"
|
||||||
die "$errmsg"
|
fi
|
||||||
fi;;
|
done
|
||||||
|
cleanup ;;
|
||||||
|
|
||||||
"do" )
|
"do" )
|
||||||
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
||||||
|
|||||||
Reference in New Issue
Block a user