diff --git a/tests/t1550-done.sh b/tests/t1550-done.sh new file mode 100755 index 0000000..583ae70 --- /dev/null +++ b/tests/t1550-done.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +test_description='done functionality +' +. ./test-lib.sh + +#DATE=`date '+%Y-%m-%d'` + +test_todo_session 'done usage' <>> export TODOTXT_FORCE=1 + +>>> todo.sh done +usage: todo.sh done "TODO ITEM" +=== 1 +EOF + +cat > todo.txt <>> todo.sh lsa +2 remove1 +3 remove2 +4 remove3 +5 remove4 +1 stop +-- +TODO: 5 of 5 tasks shown + +>>> todo.sh done smell the uppercase Roses +TODO: 'smell the uppercase Roses' marked as done. + +>>> todo.sh done notice the sunflowers +TODO: 'notice the sunflowers' marked as done. + +>>> todo.sh lsa +2 remove1 +3 remove2 +4 remove3 +5 remove4 +1 stop +7 x 2009-02-13 notice the sunflowers +6 x 2009-02-13 smell the uppercase Roses +-- +TODO: 7 of 7 tasks shown +EOF +test_done diff --git a/todo.sh b/todo.sh index 3cbebe3..640b348 100755 --- a/todo.sh +++ b/todo.sh @@ -799,6 +799,26 @@ case $action in fi cleanup ;; +"done" ) + if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then + echo -n "Done: " + read input + else + [ -z "$2" ] && die "usage: $TODO_SH done \"TODO ITEM\"" + shift + input=$* + fi + + now=`date '+%Y-%m-%d'` + # remove priority once item is done + newtodo=$(sed -e "s/^(.) // ; s|^|&x $now |" <<<${input}) + echo "$newtodo" >> "$DONE_FILE" + [ $TODOTXT_VERBOSE -gt 0 ] && { + echo "TODO: '$input' marked as done." + } + + cleanup;; + "help" ) if [ -t 1 ] ; then # STDOUT is a TTY if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then