Compare commits

..

15 Commits

Author SHA1 Message Date
Ingo Karkat
cb53da0c96 Create dedicated test file for report tests. 2012-01-14 21:48:48 +01:00
Ingo Karkat
8e3f2712a8 ENH: Only add new data to report.
When the last reported values are identical to the current values, do not append the same information (just with a new timestamp) to the report. Instead, just print the last report line.

With this, the report action can be scheduled periodically (e.g. via cron) without artificially inflating the report file.
2012-01-14 15:21:53 +01:00
Ingo Karkat
20b7ef6964 Align report order with other actions.
Like "add" or "do", first the object, then (in verbose mode) the status message is printed.
2012-01-14 15:10:22 +01:00
Ingo Karkat
45e9dc7550 Use ISO 8601 timestamp format.
IMO 2012-01-14T14:49 looks better than the messy -*-*-*- of 2012-01-14-14:49, and is more aligned with standards.
2012-01-14 15:04:55 +01:00
Ingo Karkat
a8df23ec3c Simplify writing of report line. 2012-01-14 14:58:58 +01:00
Ingo Karkat
6d860d2506 Only print the added report line, not entire report.
I think this makes much more sense, especially once the report gets very long. (One can always use "cat" to view the entire report.)
2012-01-14 14:56:03 +01:00
Ingo Karkat
a686659985 Remove inactive broken report header.
This was meant to write a report header on the initial report run, but as it mistakenly used TODO_FILE instead of REPORT_FILE, it was inactive, and also missing in the tests. Let's just remove it; the format is simple, anyway.
2012-01-14 14:41:58 +01:00
Gina Trapani
f8a6e5f8d6 Merge pull request #59 from inkarkat/bug-pri-no-existence-check
BUG: pri doesn't issue an error when the task does not exist.
2011-12-18 21:50:18 -08:00
Ingo Karkat
388ae745af Refactoring: Extract getPrefix() for more consistent move error.
I think that the error on the "move dest src" action should be given like "SRC: No task 42" instead of "TODO: No task 42 in /path/to/src.txt", to be consistent with the addto and listfile actions. Extracted and exposed getPrefix(), again to remove a bit of duplication, and because this can be useful in custom add-ons, too.
2011-12-18 21:44:47 +01:00
Ingo Karkat
cb908bd454 Refactoring: Extract getTodo() and getNewtodo() functions.
The retrieval of a task text for $item and associated error handling so far was scattered around the individual actions. This is now consolidated in two new utility functions, which directly set $todo or $newtodo, respectively. (Inconsistent variable names like $NEWTODO have been adapted.) This ensures that all actions perform the same error checking, reduces a bit of duplication, and allows custom add-ons to benefit from these exported functions. Ah, and the error messages for the "move" action is now more in line with the other errors; unfortunately, this isn't yet covered by a test.

Note that the check whether $item is numeric must not use the +([0-9]) extglob any more, as such functions cannot be exported; a new Bash doesn't have the "shopt -s extglob" and complains with a syntax error. Fortunately, it is possible to perform the same check via standard Bash mechanisms.
2011-12-17 23:26:25 +01:00
Ingo Karkat
55679d136f BUG: pri doesn't issue error when task does not exist. 2011-12-17 21:29:18 +01:00
Gina Trapani
c0847b0b25 Merge pull request #58 from inkarkat/bug-quoting-negative-term
FIX: Correct quoting for negative -TERM filtering.
2011-12-07 09:31:28 -08:00
Gina Trapani
76fb1cb3ee Merge pull request #57 from inkarkat/filename-completion
Add file completion for addto, listfile, and move.
2011-12-07 09:21:17 -08:00
Gina Trapani
ac090fa30b Merge pull request #56 from inkarkat/todo_completion
Incorporate Bash completion from the Wiki page into the distribution.
2011-12-07 09:20:07 -08:00
Ingo Karkat
ea0e7c7b25 FIX: Correct quoting for negative -TERM filtering.
This oversight was recently introduced with the new filtercommand() in a0f39480bf.
I've enhanced the test to cover -TERM filtering, too.
2011-12-03 16:55:13 +01:00
5 changed files with 209 additions and 69 deletions

View File

@@ -66,6 +66,12 @@ TODO: 4 added.
TODO: 4 of 4 tasks shown TODO: 4 of 4 tasks shown
EOF EOF
test_todo_session 'priority error' <<EOF
>>> todo.sh pri 10 B
=== 1
TODO: No task 10.
EOF
cat > todo.txt <<EOF cat > todo.txt <<EOF
(B) smell the uppercase Roses +flowers @outside (B) smell the uppercase Roses +flowers @outside
(C) notice the sunflowers (C) notice the sunflowers

View File

@@ -73,6 +73,29 @@ TODO: 1 of 3 tasks shown
TODO: 1 of 3 tasks shown TODO: 1 of 3 tasks shown
EOF EOF
#
# check negative filtering via -TERM
#
test_todo_session 'checking negative filtering via -TERM' <<EOF
>>> todo.sh ls -second
2 aaa zzz this line should be first.
1 ccc xxx this line should be third.
--
TODO: 2 of 3 tasks shown
>>> todo.sh ls "-should be f"
3 bbb yyy this line should be second.
1 ccc xxx this line should be third.
--
TODO: 2 of 3 tasks shown
>>> todo.sh ls "- zzz"
3 bbb yyy this line should be second.
1 ccc xxx this line should be third.
--
TODO: 2 of 3 tasks shown
EOF
# #
# check the filtering of TERM with regexp # check the filtering of TERM with regexp
# #

91
tests/t1950-report.sh Executable file
View File

@@ -0,0 +1,91 @@
#!/bin/sh
test_description='report functionality
This test checks the reporting and the format of the report file.
'
. ./test-lib.sh
cat > todo.txt <<EOF
(B) smell the uppercase Roses +flowers @outside
stop and think
smell the coffee +wakeup
make the coffee +wakeup
visit http://example.com
EOF
test_todo_session 'create new report' <<EOF
>>> todo.sh report
2009-02-13T04:40:00 5 0
TODO: Report file updated.
>>> todo.sh -p list
1 (B) smell the uppercase Roses +flowers @outside
4 make the coffee +wakeup
3 smell the coffee +wakeup
2 stop and think
5 visit http://example.com
--
TODO: 5 of 5 tasks shown
EOF
test_todo_session 'report of done tasks' <<EOF
>>> todo.sh -A do 3
3 x 2009-02-13 smell the coffee +wakeup
TODO: 3 marked as done.
x 2009-02-13 smell the coffee +wakeup
TODO: $HOME/todo.txt archived.
>>> todo.sh report
2009-02-13T04:40:00 4 1
TODO: Report file updated.
>>> todo.sh -p list
1 (B) smell the uppercase Roses +flowers @outside
3 make the coffee +wakeup
2 stop and think
4 visit http://example.com
--
TODO: 4 of 4 tasks shown
EOF
test_todo_session 'report performs archiving' <<EOF
>>> todo.sh -a do 3
3 x 2009-02-13 make the coffee +wakeup
TODO: 3 marked as done.
>>> todo.sh report
2009-02-13T04:40:00 3 2
TODO: Report file updated.
>>> todo.sh -p list
1 (B) smell the uppercase Roses +flowers @outside
2 stop and think
3 visit http://example.com
--
TODO: 3 of 3 tasks shown
>>> todo.sh -p listfile done.txt
2 x 2009-02-13 make the coffee +wakeup
1 x 2009-02-13 smell the coffee +wakeup
--
DONE: 2 of 2 tasks shown
EOF
test_todo_session 'report is unchanged when no changes' <<EOF
>>> cat report.txt
2009-02-13T04:40:00 5 0
2009-02-13T04:40:00 4 1
2009-02-13T04:40:00 3 2
>>> todo.sh report
2009-02-13T04:40:00 3 2
TODO: Report file is up-to-date.
>>> cat report.txt
2009-02-13T04:40:00 5 0
2009-02-13T04:40:00 4 1
2009-02-13T04:40:00 3 2
EOF
test_done

View File

@@ -85,13 +85,8 @@ TODO: $HOME/todo.txt archived.
TODO: 5 of 5 tasks shown TODO: 5 of 5 tasks shown
>>> todo.sh report >>> todo.sh report
2009-02-13T04:40:00 5 1
TODO: Report file updated. TODO: Report file updated.
2009-02-13-04:40:00 5 1
>>> todo.sh report
TODO: Report file updated.
2009-02-13-04:40:00 5 1
2009-02-13-04:40:00 5 1
>>> todo.sh append g a >>> todo.sh append g a
usage: todo.sh append ITEM# "TEXT TO APPEND" usage: todo.sh append ITEM# "TEXT TO APPEND"

151
todo.sh
View File

@@ -296,6 +296,11 @@ cleanup()
cleaninput() cleaninput()
{ {
# Parameters: When $1 = "for sed", performs additional escaping for use
# in sed substitution with "|" separators.
# Precondition: $input contains text to be cleaned.
# Postcondition: Modifies $input.
# Replace CR and LF with space; tasks always comprise a single line. # Replace CR and LF with space; tasks always comprise a single line.
input=${input//$'\r'/ } input=${input//$'\r'/ }
input=${input//$'\n'/ } input=${input//$'\n'/ }
@@ -310,6 +315,44 @@ cleaninput()
fi fi
} }
getPrefix()
{
# Parameters: $1: todo file; empty means $TODO_FILE.
# Returns: Uppercase FILE prefix to be used in place of "TODO:" where
# a different todo file can be specified.
local base=$(basename "${1:-$TODO_FILE}")
echo "${base%%.[^.]*}" | tr 'a-z' 'A-Z'
}
getTodo()
{
# Parameters: $1: task number
# $2: Optional todo file
# Precondition: $errmsg contains usage message.
# Postcondition: $todo contains task text.
local item=$1
[ -z "$item" ] && die "$errmsg"
[ "${item//[0-9]/}" ] && die "$errmsg"
todo=$(sed "$item!d" "${2:-$TODO_FILE}")
[ -z "$todo" ] && die "$(getPrefix "$2"): No task $item."
}
getNewtodo()
{
# Parameters: $1: task number
# $2: Optional todo file
# Precondition: None.
# Postcondition: $newtodo contains task text.
local item=$1
[ -z "$item" ] && die 'Programming error: $item should exist.'
[ "${item//[0-9]/}" ] && die 'Programming error: $item should be numeric.'
newtodo=$(sed "$item!d" "${2:-$TODO_FILE}")
[ -z "$newtodo" ] && die "$(getPrefix "$2"): No updated task $item."
}
archive() archive()
{ {
#defragment blank lines #defragment blank lines
@@ -338,12 +381,7 @@ replaceOrPrepend()
;; ;;
esac esac
shift; item=$1; shift shift; item=$1; shift
getTodo "$item"
[ -z "$item" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "TODO: No task $item."
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
echo -n "$querytext" echo -n "$querytext"
@@ -368,7 +406,7 @@ replaceOrPrepend()
# date again. # date again.
sed -i.bak -e "$item s/^${priority}${prepdate}//" -e "$item s|^.*|${priority}${prepdate}${input}${backref}|" "$TODO_FILE" sed -i.bak -e "$item s/^${priority}${prepdate}//" -e "$item s|^.*|${priority}${prepdate}${input}${backref}|" "$TODO_FILE"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
newtodo=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
case "$action" in case "$action" in
replace) replace)
echo "$item $todo" echo "$item $todo"
@@ -658,10 +696,8 @@ _addto() {
echo "$input" >> "$file" echo "$input" >> "$file"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
TASKNUM=$(sed -n '$ =' "$file") TASKNUM=$(sed -n '$ =' "$file")
BASE=$(basename "$file")
PREFIX=$(echo ${BASE%%.[^.]*} | tr 'a-z' 'A-Z')
echo "$TASKNUM $input" echo "$TASKNUM $input"
echo "${PREFIX}: $TASKNUM added." echo "$(getPrefix "$file"): $TASKNUM added."
fi fi
} }
@@ -690,7 +726,7 @@ filtercommand()
## $search_term ## $search_term
# #
## Remove the first character (-) before adding to our filter command ## Remove the first character (-) before adding to our filter command
filter="${filter:-}${filter:+ | }grep -v -i '$(shellquote "${search_term:1}")'" filter="${filter:-}${filter:+ | }grep -v -i $(shellquote "${search_term:1}")"
fi fi
done done
@@ -784,20 +820,18 @@ _list() {
[ "$filtered_items" ] && echo "$filtered_items" [ "$filtered_items" ] && echo "$filtered_items"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
BASE=$(basename "$FILE")
PREFIX=$(echo ${BASE%%.[^.]*} | tr 'a-z' 'A-Z')
NUMTASKS=$( echo -n "$filtered_items" | sed -n '$ =' ) NUMTASKS=$( echo -n "$filtered_items" | sed -n '$ =' )
TOTALTASKS=$( echo -n "$items" | sed -n '$ =' ) TOTALTASKS=$( echo -n "$items" | sed -n '$ =' )
echo "--" echo "--"
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown" echo "$(getPrefix "$FILE"): ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"
fi fi
if [ $TODOTXT_VERBOSE -gt 1 ]; then if [ $TODOTXT_VERBOSE -gt 1 ]; then
echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}" echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}"
fi fi
} }
export -f cleaninput shellquote filtercommand _list die export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list die
# == HANDLE ACTION == # == HANDLE ACTION ==
action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' )
@@ -874,11 +908,8 @@ case $action in
"append" | "app" ) "append" | "app" )
errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\"" errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\""
shift; item=$1; shift shift; item=$1; shift
getTodo "$item"
[ -z "$item" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "TODO: No task $item."
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
echo -n "Append: " echo -n "Append: "
read input read input
@@ -893,7 +924,7 @@ case $action in
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
newtodo=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
echo "$item $newtodo" echo "$item $newtodo"
fi fi
else else
@@ -908,14 +939,11 @@ case $action in
# replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 # replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
errmsg="usage: $TODO_SH del ITEM# [TERM]" errmsg="usage: $TODO_SH del ITEM# [TERM]"
item=$2 item=$2
[ -z "$item" ] && die "$errmsg" getTodo "$item"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
DELETEME=$(sed "$item!d" "$TODO_FILE")
[ -z "$DELETEME" ] && die "TODO: No task $item."
if [ -z "$3" ]; then if [ -z "$3" ]; then
if [ $TODOTXT_FORCE = 0 ]; then if [ $TODOTXT_FORCE = 0 ]; then
echo "Delete '$DELETEME'? (y/n)" echo "Delete '$todo'? (y/n)"
read ANSWER read ANSWER
else else
ANSWER="y" ANSWER="y"
@@ -929,7 +957,7 @@ case $action in
sed -i.bak -e $item"s/^.*//" "$TODO_FILE" sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
fi fi
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
echo "$item $DELETEME" echo "$item $todo"
echo "TODO: $item deleted." echo "TODO: $item deleted."
fi fi
else else
@@ -943,13 +971,13 @@ case $action in
-e $item"s/ *$3 */ /g" \ -e $item"s/ *$3 */ /g" \
-e $item"s/$3//g" \ -e $item"s/$3//g" \
"$TODO_FILE" "$TODO_FILE"
newtodo=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
if [ "$DELETEME" = "$newtodo" ]; then if [ "$todo" = "$newtodo" ]; then
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item $DELETEME" [ $TODOTXT_VERBOSE -gt 0 ] && echo "$item $todo"
die "TODO: '$3' not found; no removal done." die "TODO: '$3' not found; no removal done."
fi fi
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
echo "$item $DELETEME" echo "$item $todo"
echo "TODO: Removed '$3' from task." echo "TODO: Removed '$3' from task."
echo "$item $newtodo" echo "$item $newtodo"
fi fi
@@ -964,15 +992,13 @@ case $action in
# Split multiple depri's, if comma separated change to whitespace separated # Split multiple depri's, if comma separated change to whitespace separated
# Loop the 'depri' function for each item # Loop the 'depri' function for each item
for item in $(echo $* | tr ',' ' '); do for item in $(echo $* | tr ',' ' '); do
[[ "$item" = +([0-9]) ]] || die "$errmsg" getTodo "$item"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "TODO: No task $item."
if [[ "$todo" = \(?\)\ * ]]; then if [[ "$todo" = \(?\)\ * ]]; then
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE" sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
NEWTODO=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
echo "$item $NEWTODO" echo "$item $newtodo"
echo "TODO: $item deprioritized." echo "TODO: $item deprioritized."
fi fi
else else
@@ -990,11 +1016,7 @@ case $action in
# Split multiple do's, if comma separated change to whitespace separated # 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" getTodo "$item"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "TODO: No task $item."
# Check if this item has already been done # Check if this item has already been done
if [ "${todo:0:2}" != "x " ]; then if [ "${todo:0:2}" != "x " ]; then
@@ -1003,7 +1025,7 @@ case $action in
sed -i.bak $item"s/^(.) //" "$TODO_FILE" sed -i.bak $item"s/^(.) //" "$TODO_FILE"
sed -i.bak $item"s|^|x $now |" "$TODO_FILE" sed -i.bak $item"s|^|x $now |" "$TODO_FILE"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
newtodo=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
echo "$item $newtodo" echo "$item $newtodo"
echo "TODO: $item marked as done." echo "TODO: $item marked as done."
fi fi
@@ -1086,19 +1108,16 @@ case $action in
dest="$TODO_DIR/$3" dest="$TODO_DIR/$3"
src="$TODO_DIR/$4" src="$TODO_DIR/$4"
[ -z "$item" ] && die "$errmsg"
[ -z "$4" ] && src="$TODO_FILE" [ -z "$4" ] && src="$TODO_FILE"
[ -z "$dest" ] && die "$errmsg" [ -z "$dest" ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
[ -f "$src" ] || die "TODO: Source file $src does not exist." [ -f "$src" ] || die "TODO: Source file $src does not exist."
[ -f "$dest" ] || die "TODO: Destination file $dest does not exist." [ -f "$dest" ] || die "TODO: Destination file $dest does not exist."
MOVEME=$(sed "$item!d" "$src") getTodo "$item" "$src"
[ -z "$MOVEME" ] && die "$item: No such item in $src." [ -z "$todo" ] && die "$item: No such item in $src."
if [ $TODOTXT_FORCE = 0 ]; then if [ $TODOTXT_FORCE = 0 ]; then
echo "Move '$MOVEME' from $src to $dest? (y/n)" echo "Move '$todo' from $src to $dest? (y/n)"
read ANSWER read ANSWER
else else
ANSWER="y" ANSWER="y"
@@ -1111,10 +1130,10 @@ case $action in
# leave blank line behind (preserves line numbers) # leave blank line behind (preserves line numbers)
sed -i.bak -e $item"s/^.*//" "$src" sed -i.bak -e $item"s/^.*//" "$src"
fi fi
echo "$MOVEME" >> "$dest" echo "$todo" >> "$dest"
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
echo "$item $MOVEME" echo "$item $todo"
echo "TODO: $item moved from '$src' to '$dest'." echo "TODO: $item moved from '$src' to '$dest'."
fi fi
else else
@@ -1135,16 +1154,20 @@ case $action in
note: PRIORITY must be anywhere from A to Z." note: PRIORITY must be anywhere from A to Z."
[ "$#" -ne 3 ] && die "$errmsg" [ "$#" -ne 3 ] && die "$errmsg"
[[ "$item" = +([0-9]) ]] || die "$errmsg"
[[ "$newpri" = @([A-Z]) ]] || die "$errmsg" [[ "$newpri" = @([A-Z]) ]] || die "$errmsg"
getTodo "$item"
oldpri=
if [[ "$todo" = \(?\)\ * ]]; then
oldpri=${todo:1:1}
fi
oldpri=$(sed -ne $item's/^(\(.\)) .*/\1/p' "$TODO_FILE")
if [ "$oldpri" != "$newpri" ]; then if [ "$oldpri" != "$newpri" ]; then
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
fi fi
if [ $TODOTXT_VERBOSE -gt 0 ]; then if [ $TODOTXT_VERBOSE -gt 0 ]; then
NEWTODO=$(sed "$item!d" "$TODO_FILE") getNewtodo "$item"
echo "$item $NEWTODO" echo "$item $newtodo"
if [ "$oldpri" != "$newpri" ]; then if [ "$oldpri" != "$newpri" ]; then
if [ "$oldpri" ]; then if [ "$oldpri" ]; then
echo "TODO: $item re-prioritized from ($oldpri) to ($newpri)." echo "TODO: $item re-prioritized from ($oldpri) to ($newpri)."
@@ -1168,18 +1191,20 @@ note: PRIORITY must be anywhere from A to Z."
sed '/^x /!d' "$TODO_FILE" >> "$DONE_FILE" sed '/^x /!d' "$TODO_FILE" >> "$DONE_FILE"
sed -i.bak '/^x /d' "$TODO_FILE" sed -i.bak '/^x /d' "$TODO_FILE"
NUMLINES=$( sed -n '$ =' "$TODO_FILE" )
if [ ${NUMLINES:-0} = "0" ]; then
echo "datetime todos dones" >> "$REPORT_FILE"
fi
#now report
TOTAL=$( sed -n '$ =' "$TODO_FILE" ) TOTAL=$( sed -n '$ =' "$TODO_FILE" )
TDONE=$( sed -n '$ =' "$DONE_FILE" ) TDONE=$( sed -n '$ =' "$DONE_FILE" )
TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo ${TOTAL:-0}; echo ' '; NEWDATA="${TOTAL:-0} ${TDONE:-0}"
echo ${TDONE:-0}) LASTREPORT=$(sed -ne '$p' "$REPORT_FILE")
echo $TECHO >> "$REPORT_FILE" LASTDATA=${LASTREPORT#* } # Strip timestamp.
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated." if [ "$LASTDATA" = "$NEWDATA" ]; then
cat "$REPORT_FILE" echo "$LASTREPORT"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file is up-to-date."
else
NEWREPORT="$(date +%Y-%m-%dT%T) ${NEWDATA}"
echo "${NEWREPORT}" >> "$REPORT_FILE"
echo "${NEWREPORT}"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
fi
;; ;;
* ) * )