Skip to content

Commit

Permalink
Added warning message for todo.sh archive (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysle authored Dec 26, 2024
1 parent 0e7c091 commit 616e7a1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions tests/t1900-archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ test_todo_session 'list after archive' <<EOF
TODO: 5 of 5 tasks shown
EOF

test_todo_session 'archive warning message' <<EOF
>>> todo.sh archive
TODO: $HOME/todo.txt does not contain any done tasks.
EOF

test_done
6 changes: 3 additions & 3 deletions tests/t1950-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ EOF

test_todo_session 'create new report' <<EOF
>>> todo.sh report
TODO: $HOME/todo.txt archived.
TODO: $HOME/todo.txt does not contain any done tasks.
2009-02-13T04:40:00 5 0
TODO: Report file updated.
Expand All @@ -38,7 +38,7 @@ x 2009-02-13 smell the coffee +wakeup
TODO: $HOME/todo.txt archived.
>>> todo.sh report
TODO: $HOME/todo.txt archived.
TODO: $HOME/todo.txt does not contain any done tasks.
2009-02-13T04:40:00 4 1
TODO: Report file updated.
Expand Down Expand Up @@ -83,7 +83,7 @@ test_todo_session 'report is unchanged when no changes' <<EOF
2009-02-13T04:40:00 3 2
>>> todo.sh report
TODO: $HOME/todo.txt archived.
TODO: $HOME/todo.txt does not contain any done tasks.
2009-02-13T04:40:00 3 2
TODO: Report file is up-to-date.
Expand Down
2 changes: 1 addition & 1 deletion tests/t2200-no-done-report-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test_expect_success 'no done file has been created by the archiving' '[ ! -e don

test_todo_session 'perform report' <<EOF
>>> todo.sh -d test.cfg report
TODO: ./todo.txt archived.
TODO: ./todo.txt does not contain any done tasks.
2009-02-13T04:40:00 0 0
TODO: Report file updated.
EOF
Expand Down
2 changes: 1 addition & 1 deletion tests/t9999-testsuite_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ TODO: $HOME/todo.txt archived.
TODO: 5 of 5 tasks shown
>>> todo.sh report
TODO: $HOME/todo.txt archived.
TODO: $HOME/todo.txt does not contain any done tasks.
2009-02-13T04:40:00 5 1
TODO: Report file updated.
Expand Down
15 changes: 10 additions & 5 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1172,11 +1172,16 @@ case $action in
"archive" )
# defragment blank lines
sed -i.bak -e '/./!d' "$TODO_FILE"
[ "$TODOTXT_VERBOSE" -gt 0 ] && grep "^x " "$TODO_FILE"
grep "^x " "$TODO_FILE" >> "$DONE_FILE"
sed -i.bak '/^x /d' "$TODO_FILE"
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
echo "TODO: $TODO_FILE archived."
if grep "^x " "$TODO_FILE" >> "$DONE_FILE"; then
[ "$TODOTXT_VERBOSE" -gt 0 ] && grep "^x " "$TODO_FILE"
sed -i.bak '/^x /d' "$TODO_FILE"
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
echo "TODO: $TODO_FILE archived."
fi
else
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
echo "TODO: $TODO_FILE does not contain any done tasks."
fi
fi
;;

Expand Down

0 comments on commit 616e7a1

Please sign in to comment.