Compare commits
5 Commits
archive/fi
...
v1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77327f190f | ||
|
|
654c0c6d79 | ||
|
|
d3c14201a5 | ||
|
|
5a5f3bd24d | ||
|
|
868dad6d5c |
6
.gitattributes
vendored
Normal file
6
.gitattributes
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.git[ia]* export-ignore
|
||||
GEN-VERSION-FILE export-ignore
|
||||
Makefile export-ignore
|
||||
README.textile export-ignore
|
||||
VERSION-FILE export-ignore
|
||||
tests export-ignore
|
||||
52
tests/t1550-done.sh
Executable file
52
tests/t1550-done.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='done functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#DATE=`date '+%Y-%m-%d'`
|
||||
|
||||
test_todo_session 'done usage' <<EOF
|
||||
>>> export TODOTXT_FORCE=1
|
||||
|
||||
>>> todo.sh done
|
||||
usage: todo.sh done "TODO ITEM"
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
stop
|
||||
remove1
|
||||
remove2
|
||||
remove3
|
||||
remove4
|
||||
EOF
|
||||
|
||||
test_todo_session 'basic done' <<EOF
|
||||
>>> 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
|
||||
108
todo.sh
108
todo.sh
@@ -279,6 +279,8 @@ archive()
|
||||
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
||||
#[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed."
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $TODO_FILE archived." $TODO_FILE $DONE_FILE
|
||||
cleanup
|
||||
}
|
||||
|
||||
@@ -380,6 +382,8 @@ TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
||||
TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-}
|
||||
TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2}
|
||||
TODOTXT_FINAL_FILTER=${TODOTXT_FINAL_FILTER:-cat}
|
||||
TODOTXT_GIT_ENABLED=${TODOTXT_GIT_ENABLED:-1}
|
||||
TODOTXT_GIT_VERBOSE=${TODOTXT_GIT_VERBOSE:-0}
|
||||
|
||||
# Export all TODOTXT_* variables
|
||||
export ${!TODOTXT_@}
|
||||
@@ -480,14 +484,50 @@ _addto() {
|
||||
input="$now $input"
|
||||
fi
|
||||
echo "$input" >> "$file"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
|
||||
( [ $TODOTXT_VERBOSE -gt 0 ] || [ $TODOTXT_GIT_ENABLED -eq 1 ] ) && {
|
||||
TASKNUM=$(sed -n '$ =' "$file")
|
||||
BASE=$(basename "$file")
|
||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||
echo "${PREFIX}: '$input' added on line $TASKNUM."
|
||||
MESG="${PREFIX}: '$input' added on line $TASKNUM."
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && \
|
||||
echo $MESG
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "$MESG" $file
|
||||
}
|
||||
}
|
||||
|
||||
_commit() {
|
||||
[ -z "$1" ] && die "Fatal Error: No commit message."
|
||||
[ -z "$2" ] && die "Fatal Error: No commit files."
|
||||
MESG="$(echo $1 | sed -e 's|\\n|\n|g')"
|
||||
shift
|
||||
FILES=$*
|
||||
|
||||
if [ $TODOTXT_GIT_VERBOSE -eq 0 ] ; then
|
||||
( cd $TODO_DIR
|
||||
for file in $FILES ; do
|
||||
BASE=$(basename $file)
|
||||
git add $BASE > /dev/null 2>&1
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git add $BASE failed."
|
||||
done
|
||||
git commit -m "$MESG" > /dev/null 2>&1
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git commit failed."
|
||||
)
|
||||
else
|
||||
( cd $TODO_DIR
|
||||
for file in $FILES ; do
|
||||
BASE=$(basename $file)
|
||||
git add $BASE
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git add $BASE failed."
|
||||
done
|
||||
git commit -m "$MESG"
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git commit failed."
|
||||
)
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
_list() {
|
||||
local FILE="$1"
|
||||
## If the file starts with a "/" use absolute path. Otherwise,
|
||||
@@ -694,6 +734,9 @@ case $action in
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Appended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
else
|
||||
echo "TODO: Error appending task $item."
|
||||
fi
|
||||
@@ -702,6 +745,15 @@ case $action in
|
||||
"archive" )
|
||||
archive;;
|
||||
|
||||
"commit" )
|
||||
[ -z "$2" ] && die "usage: $TODO_SH commit MESSAGE"
|
||||
shift
|
||||
MESG=$*
|
||||
|
||||
( cd $TODO_DIR
|
||||
git commit -a -m "$MESG"
|
||||
);;
|
||||
|
||||
"del" | "rm" )
|
||||
# replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $TODO_SH del ITEM#"
|
||||
@@ -729,6 +781,8 @@ case $action in
|
||||
sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
|
||||
fi
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$DELETEME' deleted." $TODO_FILE
|
||||
cleanup
|
||||
else
|
||||
echo "TODO: No tasks were deleted."
|
||||
@@ -739,6 +793,8 @@ case $action in
|
||||
else
|
||||
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $3 removed from $item." $TODO_FILE
|
||||
fi ;;
|
||||
|
||||
"depri" | "dp" )
|
||||
@@ -759,6 +815,8 @@ case $action in
|
||||
echo "`echo "$item: $NEWTODO"`"
|
||||
echo "TODO: $item deprioritized."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$todo' deprioritized." $TODO_FILE
|
||||
cleanup
|
||||
else
|
||||
die "$errmsg"
|
||||
@@ -789,6 +847,8 @@ case $action in
|
||||
echo "$item: $newtodo"
|
||||
echo "TODO: $item marked as done."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$todo' marked as done." $TODO_FILE
|
||||
else
|
||||
echo "$item is already marked done"
|
||||
fi
|
||||
@@ -799,6 +859,28 @@ 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."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$input' marked as done." $DONE_FILE
|
||||
|
||||
cleanup;;
|
||||
|
||||
"help" )
|
||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
||||
if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then
|
||||
@@ -863,6 +945,11 @@ case $action in
|
||||
_list "$TODO_FILE" "$pri"
|
||||
;;
|
||||
|
||||
"log" | "pull" | "push" )
|
||||
( cd $TODO_DIR
|
||||
git $action
|
||||
);;
|
||||
|
||||
"move" | "mv" )
|
||||
# replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]"
|
||||
@@ -897,6 +984,9 @@ case $action in
|
||||
echo "$MOVEME" >> "$dest"
|
||||
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$MOVEME' moved from '$src' to '$dest'." \
|
||||
$src $dest
|
||||
cleanup
|
||||
else
|
||||
echo "TODO: No tasks moved."
|
||||
@@ -942,6 +1032,9 @@ case $action in
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Prepended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
else
|
||||
echo "TODO: Error prepending task $item."
|
||||
fi
|
||||
@@ -952,6 +1045,9 @@ case $action in
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Prepended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
else
|
||||
echo "TODO: Error prepending task $item."
|
||||
fi
|
||||
@@ -979,6 +1075,8 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
echo "`echo "$item: $NEWTODO"`"
|
||||
echo "TODO: $item prioritized ($newpri)."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $item prioritized ($newpri)." $TODO_FILE
|
||||
cleanup
|
||||
else
|
||||
die "$errmsg"
|
||||
@@ -1013,12 +1111,14 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
else
|
||||
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
||||
fi
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
echo "$item: $todo"
|
||||
echo "replaced with"
|
||||
echo "$item: $NEWTODO"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "$item: $todo\nreplaced with\n$item: $NEWTODO" $TODO_FILE
|
||||
cleanup;;
|
||||
|
||||
"report" )
|
||||
@@ -1037,6 +1137,8 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
echo ${TDONE:-0})
|
||||
echo $TECHO >> "$REPORT_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Report file updated." $REPORT_FILE
|
||||
cat "$REPORT_FILE"
|
||||
cleanup;;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user