Merge branch 'master' of git@github.com:ginatrapani/todo.txt-cli

This commit is contained in:
Gina Trapani
2010-06-29 10:12:56 -07:00
9 changed files with 99 additions and 33 deletions

View File

@@ -12,7 +12,8 @@ command work, including support for filtering.
#
test_todo_session 'basic add/list' <<EOF
>>> todo.sh add notice the daisies
TODO: 'notice the daisies' added on line 1.
1: notice the daisies
TODO: 1 added.
>>> todo.sh list
1 notice the daisies
@@ -20,7 +21,8 @@ TODO: 'notice the daisies' added on line 1.
TODO: 1 of 1 tasks shown
>>> todo.sh add smell the roses
TODO: 'smell the roses' added on line 2.
2: smell the roses
TODO: 2 added.
>>> todo.sh list
1 notice the daisies
@@ -46,7 +48,8 @@ EOF
test_todo_session 'case-insensitive filtering' <<EOF
>>> todo.sh add smell the uppercase Roses
TODO: 'smell the uppercase Roses' added on line 3.
3: smell the uppercase Roses
TODO: 3 added.
>>> todo.sh list roses
2 smell the roses
@@ -57,7 +60,8 @@ EOF
test_todo_session 'add with &' <<EOF
>>> todo.sh add "dig the garden & water the flowers"
TODO: 'dig the garden & water the flowers' added on line 4.
4: dig the garden & water the flowers
TODO: 4 added.
>>> todo.sh list
4 dig the garden & water the flowers

View File

@@ -12,7 +12,8 @@ a date to each item.
#
test_todo_session 'cmd line first day' <<EOF
>>> todo.sh -t add notice the daisies
TODO: '2009-02-13 notice the daisies' added on line 1.
1: 2009-02-13 notice the daisies
TODO: 1 added.
>>> todo.sh list
1 2009-02-13 notice the daisies
@@ -24,7 +25,8 @@ test_tick
test_todo_session 'cmd line second day' <<EOF
>>> todo.sh -t add smell the roses
TODO: '2009-02-14 smell the roses' added on line 2.
2: 2009-02-14 smell the roses
TODO: 2 added.
>>> todo.sh list
1 2009-02-13 notice the daisies
@@ -37,7 +39,8 @@ test_tick
test_todo_session 'cmd line third day' <<EOF
>>> todo.sh -t add mow the lawn
TODO: '2009-02-15 mow the lawn' added on line 3.
3: 2009-02-15 mow the lawn
TODO: 3 added.
>>> todo.sh list
1 2009-02-13 notice the daisies
@@ -55,7 +58,8 @@ test_tick 3600
test_todo_session 'config file third day' <<EOF
>>> todo.sh add take out the trash
TODO: '2009-02-15 take out the trash' added on line 4.
4: 2009-02-15 take out the trash
TODO: 4 added.
>>> todo.sh list
1 2009-02-13 notice the daisies

View File

@@ -19,7 +19,8 @@ touch "$HOME/garden.txt"
test_todo_session 'basic addto/listfile' <<EOF
>>> todo.sh addto garden.txt notice the daisies
GARDEN: 'notice the daisies' added on line 1.
1: notice the daisies
GARDEN: 1 added.
>>> todo.sh listfile garden.txt
1 notice the daisies
@@ -27,7 +28,8 @@ GARDEN: 'notice the daisies' added on line 1.
GARDEN: 1 of 1 tasks shown
>>> todo.sh addto garden.txt smell the roses
GARDEN: 'smell the roses' added on line 2.
2: smell the roses
GARDEN: 2 added.
>>> todo.sh listfile garden.txt
1 notice the daisies
@@ -53,7 +55,8 @@ EOF
test_todo_session 'case-insensitive filtering' <<EOF
>>> todo.sh addto garden.txt smell the uppercase Roses
GARDEN: 'smell the uppercase Roses' added on line 3.
3: smell the uppercase Roses
GARDEN: 3 added.
>>> todo.sh listfile garden.txt roses
2 smell the roses
@@ -64,7 +67,8 @@ EOF
test_todo_session 'addto with &' <<EOF
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
GARDEN: 'dig the garden & water the flowers' added on line 4.
4: dig the garden & water the flowers
GARDEN: 4 added.
>>> todo.sh listfile garden.txt
4 dig the garden & water the flowers

View File

@@ -14,7 +14,8 @@ touch "$HOME/garden.txt"
#
test_todo_session 'cmd line first day' <<EOF
>>> todo.sh -t addto garden.txt notice the daisies
GARDEN: '2009-02-13 notice the daisies' added on line 1.
1: 2009-02-13 notice the daisies
GARDEN: 1 added.
>>> todo.sh listfile garden.txt
1 2009-02-13 notice the daisies
@@ -26,7 +27,8 @@ test_tick
test_todo_session 'cmd line second day' <<EOF
>>> todo.sh -t addto garden.txt smell the roses
GARDEN: '2009-02-14 smell the roses' added on line 2.
2: 2009-02-14 smell the roses
GARDEN: 2 added.
>>> todo.sh listfile garden.txt
1 2009-02-13 notice the daisies
@@ -39,7 +41,8 @@ test_tick
test_todo_session 'cmd line third day' <<EOF
>>> todo.sh -t addto garden.txt mow the lawn
GARDEN: '2009-02-15 mow the lawn' added on line 3.
3: 2009-02-15 mow the lawn
GARDEN: 3 added.
>>> todo.sh listfile garden.txt
1 2009-02-13 notice the daisies
@@ -57,7 +60,8 @@ test_tick 3600
test_todo_session 'config file third day' <<EOF
>>> todo.sh addto garden.txt take out the trash
GARDEN: '2009-02-15 take out the trash' added on line 4.
4: 2009-02-15 take out the trash
GARDEN: 4 added.
>>> todo.sh listfile garden.txt
1 2009-02-13 notice the daisies

View File

@@ -75,7 +75,8 @@ TODO: 2 prioritized (A).
TODO: 2 of 3 tasks shown
>>> todo.sh add "smell the coffee +wakeup"
TODO: 'smell the coffee +wakeup' added on line 4.
4: smell the coffee +wakeup
TODO: 4 added.
>>> todo.sh -p list
2 (A) notice the sunflowers

View File

@@ -53,6 +53,47 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <<EOF
TODO: 3 of 3 tasks shown
EOF
#
# check the filtering of TERM
#
test_todo_session 'checking filtering of TERM' <<EOF
>>> todo.sh ls second
3 bbb yyy this line should be second.
--
TODO: 1 of 3 tasks shown
>>> todo.sh ls "should be f"
2 aaa zzz this line should be first.
--
TODO: 1 of 3 tasks shown
>>> todo.sh ls " zzz"
2 aaa zzz this line should be first.
--
TODO: 1 of 3 tasks shown
EOF
#
# check the filtering of TERM with regexp
#
test_todo_session 'checking filtering of TERM with regexp' <<EOF
>>> todo.sh ls "ir[ds]"
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 "f.*t"
2 aaa zzz this line should be first.
--
TODO: 1 of 3 tasks shown
>>> todo.sh ls "ir[ds]" xxx
1 ccc xxx this line should be third.
--
TODO: 1 of 3 tasks shown
EOF
#
# check the x command line option
#

View File

@@ -33,7 +33,8 @@ fi
## Add test
# Create the expected file
echo "TODO: 'eat apples eat oranges drink milk' added on line 2.">$HOME/expect.multi
echo "2: eat apples eat oranges drink milk
TODO: 2 added.">$HOME/expect.multi
test_expect_success 'multiline squash item add' '
(
@@ -108,9 +109,12 @@ fi
## Multiple line addition
# Create the expected file
echo "TODO: 'eat apples' added on line 2." > $HOME/expect.multi
echo "TODO: 'eat oranges' added on line 3." >>$HOME/expect.multi
echo "TODO: 'drink milk' added on line 4." >> $HOME/expect.multi
echo "2: eat apples
TODO: 2 added." > $HOME/expect.multi
echo "3: eat oranges
TODO: 3 added." >>$HOME/expect.multi
echo "4: drink milk
TODO: 4 added." >> $HOME/expect.multi
test_expect_success 'actual multiline add' '
(

View File

@@ -48,7 +48,8 @@ TODO: 2 marked as done.
TODO: 4 of 4 tasks shown
>>> todo.sh add "make the coffee +wakeup"
TODO: 'make the coffee +wakeup' added on line 5.
5: make the coffee +wakeup
TODO: 5 added.
>>> todo.sh -p list coffee
5 make the coffee +wakeup
@@ -57,7 +58,8 @@ TODO: 'make the coffee +wakeup' added on line 5.
TODO: 2 of 5 tasks shown
>>> todo.sh add "visit http://example.com"
TODO: 'visit http://example.com' added on line 6.
6: visit http://example.com
TODO: 6 added.
>>> todo.sh -p list
1 (B) smell the uppercase Roses +flowers @outside
@@ -134,7 +136,8 @@ TODO: 5 of 5 tasks shown
TODO: 5 of 5 tasks shown
>>> todo.sh add "the coffee +wakeup"
TODO: 'the coffee +wakeup' added on line 6.
6: the coffee +wakeup
TODO: 6 added.
>>> todo.sh -p list
1 (B) smell the uppercase Roses +flowers @outside

19
todo.sh
View File

@@ -484,7 +484,8 @@ _addto() {
TASKNUM=$(sed -n '$ =' "$file")
BASE=$(basename "$file")
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
echo "${PREFIX}: '$input' added on line $TASKNUM."
echo "$TASKNUM: $input"
echo "${PREFIX}: $TASKNUM added."
}
}
@@ -515,10 +516,10 @@ _list() {
## Prefix the filter_command with the pre_filter_command
filter_command="${pre_filter_command:-}"
for search_term in "$@"
for search_term
do
## See if the first character of $search_term is a dash
if [ ${search_term:0:1} != '-' ]
if [ "${search_term:0:1}" != '-' ]
then
## First character isn't a dash: hide lines that don't match
## this $search_term
@@ -571,10 +572,10 @@ _list() {
| eval ${TODOTXT_SORT_COMMAND} \
| sed '''
/^[0-9]\{'$PADDING'\} x /! {
s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g;
s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g;
s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g;
s/\(.*([D-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g;
/(A)/ s|^.*|'$PRI_A'&'$DEFAULT'|
/(B)/ s|^.*|'$PRI_B'&'$DEFAULT'|
/(C)/ s|^.*|'$PRI_C'&'$DEFAULT'|
/([D-Z])/ s|^.*|'$PRI_X'&'$DEFAULT'|
}
''' \
| sed '''
@@ -760,7 +761,7 @@ case $action in
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && {
NEWTODO=$(sed "$item!d" "$TODO_FILE")
echo "`echo "$item: $NEWTODO"`"
echo "$item: $NEWTODO"
echo "TODO: $item deprioritized."
}
else
@@ -982,7 +983,7 @@ note: PRIORITY must be anywhere from A to Z."
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
[ $TODOTXT_VERBOSE -gt 0 ] && {
NEWTODO=$(sed "$item!d" "$TODO_FILE")
echo "`echo "$item: $NEWTODO"`"
echo "$item: $NEWTODO"
echo "TODO: $item prioritized ($newpri)."
}
cleanup