Merge branch 'inkarkat/master'
This commit is contained in:
@@ -87,7 +87,7 @@ EOF
|
|||||||
test_todo_session 'replace error' << EOF
|
test_todo_session 'replace error' << EOF
|
||||||
>>> todo.sh replace 10 "hej!"
|
>>> todo.sh replace 10 "hej!"
|
||||||
=== 1
|
=== 1
|
||||||
10: No such todo.
|
10: No such task.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -8,7 +8,13 @@ test_description='do functionality
|
|||||||
|
|
||||||
test_todo_session 'do usage' <<EOF
|
test_todo_session 'do usage' <<EOF
|
||||||
>>> todo.sh do B B
|
>>> todo.sh do B B
|
||||||
usage: todo.sh do ITEM#
|
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_todo_session 'do missing ITEM#' <<EOF
|
||||||
|
>>> todo.sh do
|
||||||
|
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
||||||
=== 1
|
=== 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ EOF
|
|||||||
test_todo_session 'append error' << EOF
|
test_todo_session 'append error' << EOF
|
||||||
>>> todo.sh append 10 "hej!"
|
>>> todo.sh append 10 "hej!"
|
||||||
=== 1
|
=== 1
|
||||||
10: No such todo.
|
10: No such task.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
71
tests/t1700-depri.sh
Executable file
71
tests/t1700-depri.sh
Executable file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='basic depriority functionality
|
||||||
|
'
|
||||||
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_todo_session 'depriority usage' <<EOF
|
||||||
|
>>> todo.sh depri B B
|
||||||
|
usage: todo.sh depri ITEM#[, ITEM#, ITEM#, ...]
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_todo_session 'depriority nonexistant item' <<EOF
|
||||||
|
>>> todo.sh depri 42
|
||||||
|
42: No such task.
|
||||||
|
=== 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > todo.txt <<EOF
|
||||||
|
(B) smell the uppercase Roses +flowers @outside
|
||||||
|
(A) notice the sunflowers
|
||||||
|
stop
|
||||||
|
EOF
|
||||||
|
test_todo_session 'basic depriority' <<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 1
|
||||||
|
1: smell the uppercase Roses +flowers @outside
|
||||||
|
TODO: 1 deprioritized.
|
||||||
|
|
||||||
|
>>> todo.sh -p list
|
||||||
|
2 (A) notice the sunflowers
|
||||||
|
1 smell the uppercase Roses +flowers @outside
|
||||||
|
3 stop
|
||||||
|
--
|
||||||
|
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
|
||||||
@@ -108,7 +108,7 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh append 10 "hej!"
|
>>> todo.sh append 10 "hej!"
|
||||||
10: No such todo.
|
10: No such task.
|
||||||
=== 1
|
=== 1
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -121,7 +121,7 @@ TODO: 5 of 5 tasks shown
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh do 10
|
>>> todo.sh do 10
|
||||||
10: No such todo.
|
10: No such task.
|
||||||
=== 1
|
=== 1
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
|
|||||||
132
todo.sh
132
todo.sh
@@ -44,12 +44,12 @@ shorthelp()
|
|||||||
addto DEST "TEXT TO ADD"
|
addto DEST "TEXT TO ADD"
|
||||||
addm "THINGS I NEED TO DO
|
addm "THINGS I NEED TO DO
|
||||||
MORE THINGS I NEED TO DO"
|
MORE THINGS I NEED TO DO"
|
||||||
append|app NUMBER "TEXT TO APPEND"
|
append|app ITEM# "TEXT TO APPEND"
|
||||||
archive
|
archive
|
||||||
command [ACTIONS]
|
command [ACTIONS]
|
||||||
del|rm NUMBER [TERM]
|
del|rm ITEM# [TERM]
|
||||||
dp|depri NUMBER
|
dp|depri ITEM#[, ITEM#, ITEM#, ...]
|
||||||
do NUMBER
|
do ITEM#[, ITEM#, ITEM#, ...]
|
||||||
help
|
help
|
||||||
list|ls [TERM...]
|
list|ls [TERM...]
|
||||||
listall|lsa [TERM...]
|
listall|lsa [TERM...]
|
||||||
@@ -57,10 +57,10 @@ shorthelp()
|
|||||||
listfile|lf SRC [TERM...]
|
listfile|lf SRC [TERM...]
|
||||||
listpri|lsp [PRIORITY]
|
listpri|lsp [PRIORITY]
|
||||||
listproj|lsprj
|
listproj|lsprj
|
||||||
move|mv NUMBER DEST [SRC]
|
move|mv ITEM# DEST [SRC]
|
||||||
prepend|prep NUMBER "TEXT TO PREPEND"
|
prepend|prep ITEM# "TEXT TO PREPEND"
|
||||||
pri|p NUMBER PRIORITY
|
pri|p ITEM# PRIORITY
|
||||||
replace NUMBER "UPDATED TODO"
|
replace ITEM# "UPDATED TODO"
|
||||||
report
|
report
|
||||||
|
|
||||||
See "help" for more details.
|
See "help" for more details.
|
||||||
@@ -91,37 +91,37 @@ help()
|
|||||||
Adds a line of text to any file located in the todo.txt directory.
|
Adds a line of text to any file located in the todo.txt directory.
|
||||||
For example, addto inbox.txt "decide about vacation"
|
For example, addto inbox.txt "decide about vacation"
|
||||||
|
|
||||||
append NUMBER "TEXT TO APPEND"
|
append ITEM# "TEXT TO APPEND"
|
||||||
app NUMBER "TEXT TO APPEND"
|
app ITEM# "TEXT TO APPEND"
|
||||||
Adds TEXT TO APPEND to the end of the todo on line NUMBER.
|
Adds TEXT TO APPEND to the end of the task on line ITEM#.
|
||||||
Quotes optional.
|
Quotes optional.
|
||||||
|
|
||||||
archive
|
archive
|
||||||
Moves done items from todo.txt to done.txt and removes blank lines.
|
Moves all done tasks from todo.txt to done.txt and removes blank lines.
|
||||||
|
|
||||||
command [ACTIONS]
|
command [ACTIONS]
|
||||||
Runs the remaining arguments using only todo.sh builtins.
|
Runs the remaining arguments using only todo.sh builtins.
|
||||||
Will not call any .todo.actions.d scripts.
|
Will not call any .todo.actions.d scripts.
|
||||||
|
|
||||||
del NUMBER [TERM]
|
del ITEM# [TERM]
|
||||||
rm NUMBER [TERM]
|
rm ITEM# [TERM]
|
||||||
Deletes the item on line NUMBER in todo.txt.
|
Deletes the task on line ITEM# in todo.txt.
|
||||||
If term specified, deletes only the term from the line.
|
If TERM specified, deletes only TERM from the task.
|
||||||
|
|
||||||
depri NUMBER
|
depri ITEM#[, ITEM#, ITEM#, ...]
|
||||||
dp NUMBER
|
dp ITEM#[, ITEM#, ITEM#, ...]
|
||||||
Deprioritizes (removes the priority) from the item
|
Deprioritizes (removes the priority) from the task(s)
|
||||||
on line NUMBER in todo.txt.
|
on line ITEM# in todo.txt.
|
||||||
|
|
||||||
do NUMBER[, NUMBER, NUMBER, ...]
|
do ITEM#[, ITEM#, ITEM#, ...]
|
||||||
Marks item(s) on line NUMBER as done in todo.txt.
|
Marks task(s) on line ITEM# as done in todo.txt.
|
||||||
|
|
||||||
help
|
help
|
||||||
Display this help message.
|
Display this help message.
|
||||||
|
|
||||||
list [TERM...]
|
list [TERM...]
|
||||||
ls [TERM...]
|
ls [TERM...]
|
||||||
Displays all todo's that contain TERM(s) sorted by priority with line
|
Displays all tasks that contain TERM(s) sorted by priority with line
|
||||||
numbers. If no TERM specified, lists entire todo.txt.
|
numbers. If no TERM specified, lists entire todo.txt.
|
||||||
|
|
||||||
listall [TERM...]
|
listall [TERM...]
|
||||||
@@ -142,36 +142,36 @@ help()
|
|||||||
|
|
||||||
listpri [PRIORITY]
|
listpri [PRIORITY]
|
||||||
lsp [PRIORITY]
|
lsp [PRIORITY]
|
||||||
Displays all items prioritized PRIORITY.
|
Displays all tasks prioritized PRIORITY.
|
||||||
If no PRIORITY specified, lists all prioritized items.
|
If no PRIORITY specified, lists all prioritized tasks.
|
||||||
|
|
||||||
listproj
|
listproj
|
||||||
lsprj
|
lsprj
|
||||||
Lists all the projects that start with the + sign in todo.txt.
|
Lists all the projects that start with the + sign in todo.txt.
|
||||||
|
|
||||||
move NUMBER DEST [SRC]
|
move ITEM# DEST [SRC]
|
||||||
mv NUMBER DEST [SRC]
|
mv ITEM# DEST [SRC]
|
||||||
Moves a line from source text file (SRC) to destination text file (DEST).
|
Moves a line from source text file (SRC) to destination text file (DEST).
|
||||||
Both source and destination file must be located in the directory defined
|
Both source and destination file must be located in the directory defined
|
||||||
in the configuration directory. When SRC is not defined
|
in the configuration directory. When SRC is not defined
|
||||||
it's by default todo.txt.
|
it's by default todo.txt.
|
||||||
|
|
||||||
prepend NUMBER "TEXT TO PREPEND"
|
prepend ITEM# "TEXT TO PREPEND"
|
||||||
prep NUMBER "TEXT TO PREPEND"
|
prep ITEM# "TEXT TO PREPEND"
|
||||||
Adds TEXT TO PREPEND to the beginning of the todo on line NUMBER.
|
Adds TEXT TO PREPEND to the beginning of the task on line ITEM#.
|
||||||
Quotes optional.
|
Quotes optional.
|
||||||
|
|
||||||
pri NUMBER PRIORITY
|
pri ITEM# PRIORITY
|
||||||
p NUMBER PRIORITY
|
p ITEM# PRIORITY
|
||||||
Adds PRIORITY to todo on line NUMBER. If the item is already
|
Adds PRIORITY to task on line ITEM#. If the task is already
|
||||||
prioritized, replaces current priority with new PRIORITY.
|
prioritized, replaces current priority with new PRIORITY.
|
||||||
PRIORITY must be an uppercase letter between A and Z.
|
PRIORITY must be an uppercase letter between A and Z.
|
||||||
|
|
||||||
replace NUMBER "UPDATED TODO"
|
replace ITEM# "UPDATED TODO"
|
||||||
Replaces todo on line NUMBER with UPDATED TODO.
|
Replaces task on line ITEM# with UPDATED TODO.
|
||||||
|
|
||||||
report
|
report
|
||||||
Adds the number of open todo's and closed done's to report.txt.
|
Adds the number of open tasks and done tasks to report.txt.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -680,7 +680,7 @@ case $action in
|
|||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such task."
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Append: "
|
echo -n "Append: "
|
||||||
read input
|
read input
|
||||||
@@ -734,7 +734,7 @@ case $action in
|
|||||||
echo "TODO: No tasks were deleted."
|
echo "TODO: No tasks were deleted."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$item: No such todo."
|
echo "$item: No such task."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
||||||
@@ -742,41 +742,47 @@ 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"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
# Split multiple depri's, if comma separated change to whitespace separated
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
# Loop the 'depri' function for each item
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
for item in `echo $* | tr ',' ' '`; do
|
||||||
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
|
[ -z "$todo" ] && die "$item: No such task."
|
||||||
|
|
||||||
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#"
|
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
||||||
# shift so we get arguments to the do request
|
# shift so we get arguments to the do request
|
||||||
shift;
|
shift;
|
||||||
|
[ "$#" -eq 0 ] && die "$errmsg"
|
||||||
|
|
||||||
# Split multiple do's, if comma seperated change to whitespace sepereated
|
# 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"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such task."
|
||||||
|
|
||||||
# Check if this item has already been done
|
# Check if this item has already been done
|
||||||
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
||||||
@@ -801,9 +807,9 @@ case $action in
|
|||||||
|
|
||||||
"help" )
|
"help" )
|
||||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
if [ -t 1 ] ; then # STDOUT is a TTY
|
||||||
if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then
|
if which "${PAGER:-less}" >/dev/null 2>&1; then
|
||||||
# we have a working PAGER (or less as a default)
|
# we have a working PAGER (or less as a default)
|
||||||
help | exec ${PAGER:-less}
|
help | "${PAGER:-less}" && exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
help # just in case something failed above, we go ahead and just spew to STDOUT
|
help # just in case something failed above, we go ahead and just spew to STDOUT
|
||||||
@@ -920,7 +926,7 @@ case $action in
|
|||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such task."
|
||||||
|
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Prepend: "
|
echo -n "Prepend: "
|
||||||
@@ -992,7 +998,7 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such task."
|
||||||
|
|
||||||
# Test for then set priority
|
# Test for then set priority
|
||||||
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user