From 70b2c4ca40c9458671fc3c10e1d239d9967a210a Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 4 Jun 2010 16:50:09 +0200 Subject: [PATCH] Made verbose message of _addto() consistent with other task messages. In verbose mode, commands first print the updated task, then summarize the change in the following line. The add/addm/addto commands deviated from this, using "TODO: '' added on line N." This change splits this into two separate lines, obsoletes the implementation jargon of "line", and makes it easier to visually parse the message. This is also a preparation for a possible future use of a _list()-like function, so that the updated task is processed and highlighted like the normal task output. --- tests/t1000-addlist.sh | 12 ++++++++---- tests/t1010-add-date.sh | 12 ++++++++---- tests/t1020-addtolistfile.sh | 12 ++++++++---- tests/t1030-addto-date.sh | 12 ++++++++---- tests/t1200-pri.sh | 3 ++- tests/t2000-multiline.sh | 12 ++++++++---- tests/t9999-testsuite_example.sh | 9 ++++++--- todo.sh | 3 ++- 8 files changed, 50 insertions(+), 25 deletions(-) diff --git a/tests/t1000-addlist.sh b/tests/t1000-addlist.sh index f881f8b..42e16e8 100755 --- a/tests/t1000-addlist.sh +++ b/tests/t1000-addlist.sh @@ -12,7 +12,8 @@ command work, including support for filtering. # test_todo_session 'basic add/list' <>> 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' <>> 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 &' <>> 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 diff --git a/tests/t1010-add-date.sh b/tests/t1010-add-date.sh index 50629ca..603d199 100755 --- a/tests/t1010-add-date.sh +++ b/tests/t1010-add-date.sh @@ -12,7 +12,8 @@ a date to each item. # test_todo_session 'cmd line first day' <>> 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' <>> 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' <>> 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' <>> 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 diff --git a/tests/t1020-addtolistfile.sh b/tests/t1020-addtolistfile.sh index 760a8f5..575fb16 100755 --- a/tests/t1020-addtolistfile.sh +++ b/tests/t1020-addtolistfile.sh @@ -19,7 +19,8 @@ touch "$HOME/garden.txt" test_todo_session 'basic addto/listfile' <>> 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' <>> 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 &' <>> 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 diff --git a/tests/t1030-addto-date.sh b/tests/t1030-addto-date.sh index 8f05aa4..899794d 100755 --- a/tests/t1030-addto-date.sh +++ b/tests/t1030-addto-date.sh @@ -14,7 +14,8 @@ touch "$HOME/garden.txt" # test_todo_session 'cmd line first day' <>> 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' <>> 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' <>> 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' <>> 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 diff --git a/tests/t1200-pri.sh b/tests/t1200-pri.sh index 4326470..b8742e2 100755 --- a/tests/t1200-pri.sh +++ b/tests/t1200-pri.sh @@ -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 diff --git a/tests/t2000-multiline.sh b/tests/t2000-multiline.sh index 43ab362..3eaf742 100755 --- a/tests/t2000-multiline.sh +++ b/tests/t2000-multiline.sh @@ -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' ' ( diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index 13d6fcc..64994e3 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -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 diff --git a/todo.sh b/todo.sh index b82c234..fc1fd16 100755 --- a/todo.sh +++ b/todo.sh @@ -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." } }