Compare commits
5 Commits
| 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
|
||||||
@@ -10,7 +10,7 @@ to find it somewhere else.
|
|||||||
|
|
||||||
# Remove the pre-created todo.cfg to test behavior in its absence
|
# Remove the pre-created todo.cfg to test behavior in its absence
|
||||||
rm -f todo.cfg
|
rm -f todo.cfg
|
||||||
echo "Fatal Error: Cannot read configuration file $HOME/.todo/config" > expect
|
echo "Fatal error: Cannot read configuration file $HOME/.todo/config" > expect
|
||||||
test_expect_success 'no config file' '
|
test_expect_success 'no config file' '
|
||||||
todo.sh > output 2>&1 || test_cmp expect output
|
todo.sh > output 2>&1 || test_cmp expect output
|
||||||
'
|
'
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test_description='todo.sh actions.d
|
|
||||||
|
|
||||||
This test just makes sure that todo.sh can locate custom actions.
|
|
||||||
'
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
# All the below tests will output the custom action message
|
|
||||||
cat > expect << EOF
|
|
||||||
TODO: foo
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > foo << EOF
|
|
||||||
echo "TODO: foo"
|
|
||||||
EOF
|
|
||||||
chmod +x foo
|
|
||||||
|
|
||||||
test_expect_success 'custom action (default location 1)' '
|
|
||||||
mkdir .todo.actions.d
|
|
||||||
cp foo .todo.actions.d/
|
|
||||||
todo.sh foo > output;
|
|
||||||
test_cmp expect output && rm -rf .todo.actions.d
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'custom action (default location 2)' '
|
|
||||||
mkdir -p .todo/actions
|
|
||||||
cp foo .todo/actions/
|
|
||||||
todo.sh foo > output;
|
|
||||||
test_cmp expect output && rm -rf .todo/actions
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'custom action (env variable)' '
|
|
||||||
mkdir myactions
|
|
||||||
cp foo myactions/
|
|
||||||
TODO_ACTIONS_DIR=myactions todo.sh foo > output;
|
|
||||||
test_cmp expect output && rm -rf myactions
|
|
||||||
'
|
|
||||||
|
|
||||||
test_done
|
|
||||||
@@ -12,8 +12,7 @@ command work, including support for filtering.
|
|||||||
#
|
#
|
||||||
test_todo_session 'basic add/list' <<EOF
|
test_todo_session 'basic add/list' <<EOF
|
||||||
>>> todo.sh add notice the daisies
|
>>> todo.sh add notice the daisies
|
||||||
1 notice the daisies
|
TODO: 'notice the daisies' added on line 1.
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 notice the daisies
|
1 notice the daisies
|
||||||
@@ -21,8 +20,7 @@ TODO: 1 added.
|
|||||||
TODO: 1 of 1 tasks shown
|
TODO: 1 of 1 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add smell the roses
|
>>> todo.sh add smell the roses
|
||||||
2 smell the roses
|
TODO: 'smell the roses' added on line 2.
|
||||||
TODO: 2 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 notice the daisies
|
1 notice the daisies
|
||||||
@@ -48,8 +46,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'case-insensitive filtering' <<EOF
|
test_todo_session 'case-insensitive filtering' <<EOF
|
||||||
>>> todo.sh add smell the uppercase Roses
|
>>> todo.sh add smell the uppercase Roses
|
||||||
3 smell the uppercase Roses
|
TODO: 'smell the uppercase Roses' added on line 3.
|
||||||
TODO: 3 added.
|
|
||||||
|
|
||||||
>>> todo.sh list roses
|
>>> todo.sh list roses
|
||||||
2 smell the roses
|
2 smell the roses
|
||||||
@@ -60,8 +57,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'add with &' <<EOF
|
test_todo_session 'add with &' <<EOF
|
||||||
>>> todo.sh add "dig the garden & water the flowers"
|
>>> todo.sh add "dig the garden & water the flowers"
|
||||||
4 dig the garden & water the flowers
|
TODO: 'dig the garden & water the flowers' added on line 4.
|
||||||
TODO: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
4 dig the garden & water the flowers
|
4 dig the garden & water the flowers
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ a date to each item.
|
|||||||
#
|
#
|
||||||
test_todo_session 'cmd line first day' <<EOF
|
test_todo_session 'cmd line first day' <<EOF
|
||||||
>>> todo.sh -t add notice the daisies
|
>>> todo.sh -t add notice the daisies
|
||||||
1 2009-02-13 notice the daisies
|
TODO: '2009-02-13 notice the daisies' added on line 1.
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -25,8 +24,7 @@ test_tick
|
|||||||
|
|
||||||
test_todo_session 'cmd line second day' <<EOF
|
test_todo_session 'cmd line second day' <<EOF
|
||||||
>>> todo.sh -t add smell the roses
|
>>> todo.sh -t add smell the roses
|
||||||
2 2009-02-14 smell the roses
|
TODO: '2009-02-14 smell the roses' added on line 2.
|
||||||
TODO: 2 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -39,8 +37,7 @@ test_tick
|
|||||||
|
|
||||||
test_todo_session 'cmd line third day' <<EOF
|
test_todo_session 'cmd line third day' <<EOF
|
||||||
>>> todo.sh -t add mow the lawn
|
>>> todo.sh -t add mow the lawn
|
||||||
3 2009-02-15 mow the lawn
|
TODO: '2009-02-15 mow the lawn' added on line 3.
|
||||||
TODO: 3 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -58,8 +55,7 @@ test_tick 3600
|
|||||||
|
|
||||||
test_todo_session 'config file third day' <<EOF
|
test_todo_session 'config file third day' <<EOF
|
||||||
>>> todo.sh add take out the trash
|
>>> todo.sh add take out the trash
|
||||||
4 2009-02-15 take out the trash
|
TODO: '2009-02-15 take out the trash' added on line 4.
|
||||||
TODO: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
|
|||||||
@@ -13,15 +13,13 @@ commands work, including support for filtering.
|
|||||||
test_todo_session 'nonexistant file' <<EOF
|
test_todo_session 'nonexistant file' <<EOF
|
||||||
>>> todo.sh addto garden.txt notice the daisies
|
>>> todo.sh addto garden.txt notice the daisies
|
||||||
TODO: Destination file $HOME/garden.txt does not exist.
|
TODO: Destination file $HOME/garden.txt does not exist.
|
||||||
=== 1
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
touch "$HOME/garden.txt"
|
touch "$HOME/garden.txt"
|
||||||
|
|
||||||
test_todo_session 'basic addto/listfile' <<EOF
|
test_todo_session 'basic addto/listfile' <<EOF
|
||||||
>>> todo.sh addto garden.txt notice the daisies
|
>>> todo.sh addto garden.txt notice the daisies
|
||||||
1 notice the daisies
|
GARDEN: 'notice the daisies' added on line 1.
|
||||||
GARDEN: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 notice the daisies
|
1 notice the daisies
|
||||||
@@ -29,8 +27,7 @@ GARDEN: 1 added.
|
|||||||
GARDEN: 1 of 1 tasks shown
|
GARDEN: 1 of 1 tasks shown
|
||||||
|
|
||||||
>>> todo.sh addto garden.txt smell the roses
|
>>> todo.sh addto garden.txt smell the roses
|
||||||
2 smell the roses
|
GARDEN: 'smell the roses' added on line 2.
|
||||||
GARDEN: 2 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 notice the daisies
|
1 notice the daisies
|
||||||
@@ -56,8 +53,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'case-insensitive filtering' <<EOF
|
test_todo_session 'case-insensitive filtering' <<EOF
|
||||||
>>> todo.sh addto garden.txt smell the uppercase Roses
|
>>> todo.sh addto garden.txt smell the uppercase Roses
|
||||||
3 smell the uppercase Roses
|
GARDEN: 'smell the uppercase Roses' added on line 3.
|
||||||
GARDEN: 3 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt roses
|
>>> todo.sh listfile garden.txt roses
|
||||||
2 smell the roses
|
2 smell the roses
|
||||||
@@ -68,8 +64,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'addto with &' <<EOF
|
test_todo_session 'addto with &' <<EOF
|
||||||
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
|
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
|
||||||
4 dig the garden & water the flowers
|
GARDEN: 'dig the garden & water the flowers' added on line 4.
|
||||||
GARDEN: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
4 dig the garden & water the flowers
|
4 dig the garden & water the flowers
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ touch "$HOME/garden.txt"
|
|||||||
#
|
#
|
||||||
test_todo_session 'cmd line first day' <<EOF
|
test_todo_session 'cmd line first day' <<EOF
|
||||||
>>> todo.sh -t addto garden.txt notice the daisies
|
>>> todo.sh -t addto garden.txt notice the daisies
|
||||||
1 2009-02-13 notice the daisies
|
GARDEN: '2009-02-13 notice the daisies' added on line 1.
|
||||||
GARDEN: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -27,8 +26,7 @@ test_tick
|
|||||||
|
|
||||||
test_todo_session 'cmd line second day' <<EOF
|
test_todo_session 'cmd line second day' <<EOF
|
||||||
>>> todo.sh -t addto garden.txt smell the roses
|
>>> todo.sh -t addto garden.txt smell the roses
|
||||||
2 2009-02-14 smell the roses
|
GARDEN: '2009-02-14 smell the roses' added on line 2.
|
||||||
GARDEN: 2 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -41,8 +39,7 @@ test_tick
|
|||||||
|
|
||||||
test_todo_session 'cmd line third day' <<EOF
|
test_todo_session 'cmd line third day' <<EOF
|
||||||
>>> todo.sh -t addto garden.txt mow the lawn
|
>>> todo.sh -t addto garden.txt mow the lawn
|
||||||
3 2009-02-15 mow the lawn
|
GARDEN: '2009-02-15 mow the lawn' added on line 3.
|
||||||
GARDEN: 3 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
@@ -60,8 +57,7 @@ test_tick 3600
|
|||||||
|
|
||||||
test_todo_session 'config file third day' <<EOF
|
test_todo_session 'config file third day' <<EOF
|
||||||
>>> todo.sh addto garden.txt take out the trash
|
>>> todo.sh addto garden.txt take out the trash
|
||||||
4 2009-02-15 take out the trash
|
GARDEN: '2009-02-15 take out the trash' added on line 4.
|
||||||
GARDEN: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh listfile garden.txt
|
>>> todo.sh listfile garden.txt
|
||||||
1 2009-02-13 notice the daisies
|
1 2009-02-13 notice the daisies
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'basic replace' <<EOF
|
test_todo_session 'basic replace' <<EOF
|
||||||
>>> todo.sh replace 1 "smell the cows"
|
>>> todo.sh replace 1 "smell the cows"
|
||||||
1 notice the daisies
|
1: notice the daisies
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
1 smell the cows
|
1: smell the cows
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 smell the cows
|
1 smell the cows
|
||||||
@@ -29,9 +29,9 @@ TODO: Replaced task with:
|
|||||||
TODO: 1 of 1 tasks shown
|
TODO: 1 of 1 tasks shown
|
||||||
|
|
||||||
>>> todo.sh replace 1 smell the roses
|
>>> todo.sh replace 1 smell the roses
|
||||||
1 smell the cows
|
1: smell the cows
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
1 smell the roses
|
1: smell the roses
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 smell the roses
|
1 smell the roses
|
||||||
@@ -47,88 +47,42 @@ chase the chickens
|
|||||||
EOF
|
EOF
|
||||||
test_todo_session 'replace in multi-item file' <<EOF
|
test_todo_session 'replace in multi-item file' <<EOF
|
||||||
>>> todo.sh replace 1 smell the cheese
|
>>> todo.sh replace 1 smell the cheese
|
||||||
1 smell the cows
|
1: smell the cows
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
1 smell the cheese
|
1: smell the cheese
|
||||||
|
|
||||||
>>> todo.sh replace 3 jump on hay
|
>>> todo.sh replace 3 jump on hay
|
||||||
3 thrash some hay
|
3: thrash some hay
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
3 jump on hay
|
3: jump on hay
|
||||||
|
|
||||||
>>> todo.sh replace 4 collect the eggs
|
>>> todo.sh replace 4 collect the eggs
|
||||||
4 chase the chickens
|
4: chase the chickens
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
4 collect the eggs
|
4: collect the eggs
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_todo_session 'replace with priority' <<EOF
|
test_todo_session 'replace with priority' <<EOF
|
||||||
>>> todo.sh pri 4 a
|
>>> todo.sh pri 4 a
|
||||||
4 (A) collect the eggs
|
4: (A) collect the eggs
|
||||||
TODO: 4 prioritized (A).
|
TODO: 4 prioritized (A).
|
||||||
|
|
||||||
>>> todo.sh replace 4 "collect the bread"
|
>>> todo.sh replace 4 "collect the bread"
|
||||||
4 (A) collect the eggs
|
4: (A) collect the eggs
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
4 (A) collect the bread
|
4: (A) collect the bread
|
||||||
|
|
||||||
>>> todo.sh replace 4 collect the eggs
|
|
||||||
4 (A) collect the bread
|
|
||||||
TODO: Replaced task with:
|
|
||||||
4 (A) collect the eggs
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_todo_session 'replace with &' << EOF
|
test_todo_session 'replace with &' << EOF
|
||||||
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"
|
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"
|
||||||
3 jump on hay
|
3: jump on hay
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
3 thrash the hay & thresh the wheat
|
3: thrash the hay & thresh the wheat
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_todo_session 'replace error' << EOF
|
test_todo_session 'replace error' << EOF
|
||||||
>>> todo.sh replace 10 "hej!"
|
>>> todo.sh replace 10 "hej!"
|
||||||
=== 1
|
=== 1
|
||||||
TODO: No task 10.
|
10: No such todo.
|
||||||
EOF
|
|
||||||
|
|
||||||
cat /dev/null > todo.txt
|
|
||||||
test_todo_session 'replace handling prepended date on add' <<EOF
|
|
||||||
>>> todo.sh -t add "new task"
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh replace 1 this is just a new one
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: Replaced task with:
|
|
||||||
1 2009-02-13 this is just a new one
|
|
||||||
|
|
||||||
>>> todo.sh replace 1 2010-07-04 this also has a new date
|
|
||||||
1 2009-02-13 this is just a new one
|
|
||||||
TODO: Replaced task with:
|
|
||||||
1 2010-07-04 this also has a new date
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat /dev/null > todo.txt
|
|
||||||
test_todo_session 'replace handling priority and prepended date on add' <<EOF
|
|
||||||
>>> todo.sh -t add "new task"
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh pri 1 A
|
|
||||||
1 (A) 2009-02-13 new task
|
|
||||||
TODO: 1 prioritized (A).
|
|
||||||
|
|
||||||
>>> todo.sh replace 1 this is just a new one
|
|
||||||
1 (A) 2009-02-13 new task
|
|
||||||
TODO: Replaced task with:
|
|
||||||
1 (A) 2009-02-13 this is just a new one
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_todo_session 'replace with prepended date replaces existing date' <<EOF
|
|
||||||
>>> todo.sh replace 1 2010-07-04 this also has a new date
|
|
||||||
1 (A) 2009-02-13 this is just a new one
|
|
||||||
TODO: Replaced task with:
|
|
||||||
1 (A) 2010-07-04 this also has a new date
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ test_todo_session 'basic priority' <<EOF
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh pri 1 B
|
>>> todo.sh pri 1 B
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1: (B) smell the uppercase Roses +flowers @outside
|
||||||
TODO: 1 prioritized (B).
|
TODO: 1 prioritized (B).
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
@@ -43,7 +43,7 @@ TODO: 3 of 3 tasks shown
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh pri 2 C
|
>>> todo.sh pri 2 C
|
||||||
2 (C) notice the sunflowers
|
2: (C) notice the sunflowers
|
||||||
TODO: 2 prioritized (C).
|
TODO: 2 prioritized (C).
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -54,7 +54,7 @@ TODO: 2 prioritized (C).
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh pri 2 A
|
>>> todo.sh pri 2 A
|
||||||
2 (A) notice the sunflowers
|
2: (A) notice the sunflowers
|
||||||
TODO: 2 prioritized (A).
|
TODO: 2 prioritized (A).
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -65,7 +65,7 @@ TODO: 2 prioritized (A).
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh pri 2 a
|
>>> todo.sh pri 2 a
|
||||||
2 (A) notice the sunflowers
|
2: (A) notice the sunflowers
|
||||||
TODO: 2 prioritized (A).
|
TODO: 2 prioritized (A).
|
||||||
|
|
||||||
>>> todo.sh -p listpri
|
>>> todo.sh -p listpri
|
||||||
@@ -75,8 +75,7 @@ TODO: 2 prioritized (A).
|
|||||||
TODO: 2 of 3 tasks shown
|
TODO: 2 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add "smell the coffee +wakeup"
|
>>> todo.sh add "smell the coffee +wakeup"
|
||||||
4 smell the coffee +wakeup
|
TODO: 'smell the coffee +wakeup' added on line 4.
|
||||||
TODO: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
2 (A) notice the sunflowers
|
2 (A) notice the sunflowers
|
||||||
|
|||||||
@@ -53,47 +53,6 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <<EOF
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
EOF
|
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
|
# check the x command line option
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -1,151 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
|
|
||||||
test_description='list highlighting
|
|
||||||
|
|
||||||
This test checks the highlighting (with colors) of prioritized tasks.
|
|
||||||
'
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
TEST_TODO_=todo.cfg
|
|
||||||
|
|
||||||
#
|
|
||||||
# check the highlighting of prioritized tasks
|
|
||||||
#
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(A) @con01 +prj01 -- Some project 01 task, pri A
|
|
||||||
(B) @con02 +prj02 -- Some project 02 task, pri B
|
|
||||||
(C) @con01 +prj01 -- Some project 01 task, pri C
|
|
||||||
(D) @con02 +prj02 -- Some project 02 task, pri D
|
|
||||||
(E) @con01 +prj01 -- Some project 01 task, pri E
|
|
||||||
(Z) @con02 +prj02 -- Some project 02 task, pri Z
|
|
||||||
@con01 +prj01 -- Some project 01 task, no priority
|
|
||||||
@con02 +prj02 -- Some project 02 task, no priority
|
|
||||||
EOF
|
|
||||||
test_todo_session 'default highlighting' <<EOF
|
|
||||||
>>> todo.sh ls
|
|
||||||
[1;33m1 (A) @con01 +prj01 -- Some project 01 task, pri A[0m
|
|
||||||
[0;32m2 (B) @con02 +prj02 -- Some project 02 task, pri B[0m
|
|
||||||
[1;34m3 (C) @con01 +prj01 -- Some project 01 task, pri C[0m
|
|
||||||
[1;37m4 (D) @con02 +prj02 -- Some project 02 task, pri D[0m
|
|
||||||
[1;37m5 (E) @con01 +prj01 -- Some project 01 task, pri E[0m
|
|
||||||
[1;37m6 (Z) @con02 +prj02 -- Some project 02 task, pri Z[0m
|
|
||||||
7 @con01 +prj01 -- Some project 01 task, no priority
|
|
||||||
8 @con02 +prj02 -- Some project 02 task, no priority
|
|
||||||
--
|
|
||||||
TODO: 8 of 8 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
#
|
|
||||||
# check changing the color definitions into something other than ANSI color
|
|
||||||
# escape sequences
|
|
||||||
#
|
|
||||||
TEST_TODO_CUSTOM=todo-custom.cfg
|
|
||||||
cat todo.cfg > "$TEST_TODO_CUSTOM"
|
|
||||||
cat >> "$TEST_TODO_CUSTOM" <<'EOF'
|
|
||||||
export YELLOW='${color yellow}'
|
|
||||||
export GREEN='${color green}'
|
|
||||||
export LIGHT_BLUE='${color LightBlue}'
|
|
||||||
export WHITE='${color white}'
|
|
||||||
export DEFAULT='${color}'
|
|
||||||
export PRI_A=$YELLOW
|
|
||||||
export PRI_B=$GREEN
|
|
||||||
export PRI_C=$LIGHT_BLUE
|
|
||||||
export PRI_X=$WHITE
|
|
||||||
EOF
|
|
||||||
test_todo_session 'customized highlighting' <<'EOF'
|
|
||||||
>>> todo.sh -d "$TEST_TODO_CUSTOM" ls
|
|
||||||
${color yellow}1 (A) @con01 +prj01 -- Some project 01 task, pri A${color}
|
|
||||||
${color green}2 (B) @con02 +prj02 -- Some project 02 task, pri B${color}
|
|
||||||
${color LightBlue}3 (C) @con01 +prj01 -- Some project 01 task, pri C${color}
|
|
||||||
${color white}4 (D) @con02 +prj02 -- Some project 02 task, pri D${color}
|
|
||||||
${color white}5 (E) @con01 +prj01 -- Some project 01 task, pri E${color}
|
|
||||||
${color white}6 (Z) @con02 +prj02 -- Some project 02 task, pri Z${color}
|
|
||||||
7 @con01 +prj01 -- Some project 01 task, no priority
|
|
||||||
8 @con02 +prj02 -- Some project 02 task, no priority
|
|
||||||
--
|
|
||||||
TODO: 8 of 8 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
#
|
|
||||||
# check defining highlightings for more priorities than the default A, B, C
|
|
||||||
#
|
|
||||||
TEST_TODO_ADDITIONAL=todo-additional.cfg
|
|
||||||
cat todo.cfg > "$TEST_TODO_ADDITIONAL"
|
|
||||||
cat >> "$TEST_TODO_ADDITIONAL" <<'EOF'
|
|
||||||
export PRI_E=$BROWN
|
|
||||||
export PRI_Z=$LIGHT_PURPLE
|
|
||||||
EOF
|
|
||||||
test_todo_session 'additional highlighting pri E+Z' <<'EOF'
|
|
||||||
>>> todo.sh -d "$TEST_TODO_ADDITIONAL" ls
|
|
||||||
[1;33m1 (A) @con01 +prj01 -- Some project 01 task, pri A[0m
|
|
||||||
[0;32m2 (B) @con02 +prj02 -- Some project 02 task, pri B[0m
|
|
||||||
[1;34m3 (C) @con01 +prj01 -- Some project 01 task, pri C[0m
|
|
||||||
[1;37m4 (D) @con02 +prj02 -- Some project 02 task, pri D[0m
|
|
||||||
[0;33m5 (E) @con01 +prj01 -- Some project 01 task, pri E[0m
|
|
||||||
[1;35m6 (Z) @con02 +prj02 -- Some project 02 task, pri Z[0m
|
|
||||||
7 @con01 +prj01 -- Some project 01 task, no priority
|
|
||||||
8 @con02 +prj02 -- Some project 02 task, no priority
|
|
||||||
--
|
|
||||||
TODO: 8 of 8 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# check changing the fallback highlighting for undefined priorities
|
|
||||||
#
|
|
||||||
TEST_TODO_PRI_X=todo-pri-x.cfg
|
|
||||||
cat todo.cfg > "$TEST_TODO_PRI_X"
|
|
||||||
cat >> "$TEST_TODO_PRI_X" <<'EOF'
|
|
||||||
export PRI_X=$BROWN
|
|
||||||
EOF
|
|
||||||
test_todo_session 'different highlighting for pri X' <<'EOF'
|
|
||||||
>>> todo.sh -d "$TEST_TODO_PRI_X" ls
|
|
||||||
[1;33m1 (A) @con01 +prj01 -- Some project 01 task, pri A[0m
|
|
||||||
[0;32m2 (B) @con02 +prj02 -- Some project 02 task, pri B[0m
|
|
||||||
[1;34m3 (C) @con01 +prj01 -- Some project 01 task, pri C[0m
|
|
||||||
[0;33m4 (D) @con02 +prj02 -- Some project 02 task, pri D[0m
|
|
||||||
[0;33m5 (E) @con01 +prj01 -- Some project 01 task, pri E[0m
|
|
||||||
[0;33m6 (Z) @con02 +prj02 -- Some project 02 task, pri Z[0m
|
|
||||||
7 @con01 +prj01 -- Some project 01 task, no priority
|
|
||||||
8 @con02 +prj02 -- Some project 02 task, no priority
|
|
||||||
--
|
|
||||||
TODO: 8 of 8 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# check highlighting of done (but not yet archived) tasks
|
|
||||||
#
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(A) smell the uppercase Roses +flowers @outside
|
|
||||||
remove1
|
|
||||||
notice the sunflowers
|
|
||||||
remove2
|
|
||||||
stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'highlighting of done tasks' <<EOF
|
|
||||||
>>> todo.sh -a do 2
|
|
||||||
2 x 2009-02-13 remove1
|
|
||||||
TODO: 2 marked as done.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
|
||||||
[1;33m1 (A) smell the uppercase Roses +flowers @outside[0m
|
|
||||||
3 notice the sunflowers
|
|
||||||
4 remove2
|
|
||||||
5 stop
|
|
||||||
[0;37m2 x 2009-02-13 remove1[0m
|
|
||||||
--
|
|
||||||
TODO: 5 of 5 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -a do 4
|
|
||||||
4 x 2009-02-13 remove2
|
|
||||||
TODO: 4 marked as done.
|
|
||||||
|
|
||||||
>>> todo.sh list
|
|
||||||
[1;33m1 (A) smell the uppercase Roses +flowers @outside[0m
|
|
||||||
3 notice the sunflowers
|
|
||||||
5 stop
|
|
||||||
[0;37m2 x 2009-02-13 remove1[0m
|
|
||||||
[0;37m4 x 2009-02-13 remove2[0m
|
|
||||||
--
|
|
||||||
TODO: 5 of 5 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_done
|
|
||||||
@@ -31,7 +31,7 @@ TODO: 3 of 3 tasks shown
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh prepend 2 test
|
>>> todo.sh prepend 2 test
|
||||||
2 test notice the sunflowers
|
2: test notice the sunflowers
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
@@ -41,7 +41,7 @@ TODO: 3 of 3 tasks shown
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> todo.sh prepend 1 test
|
>>> todo.sh prepend 1 test
|
||||||
1 (B) test smell the uppercase Roses +flowers @outside
|
1: (B) test smell the uppercase Roses +flowers @outside
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) test smell the uppercase Roses +flowers @outside
|
1 (B) test smell the uppercase Roses +flowers @outside
|
||||||
@@ -54,41 +54,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'prepend with &' <<EOF
|
test_todo_session 'prepend with &' <<EOF
|
||||||
>>> todo.sh prepend 3 "no running & jumping now"
|
>>> todo.sh prepend 3 "no running & jumping now"
|
||||||
3 no running & jumping now stop
|
3: no running & jumping now stop
|
||||||
EOF
|
|
||||||
|
|
||||||
cat /dev/null > todo.txt
|
|
||||||
test_todo_session 'prepend handling prepended date on add' <<EOF
|
|
||||||
>>> todo.sh -t add "new task"
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh prepend 1 "this is just a"
|
|
||||||
1 2009-02-13 this is just a new task
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat /dev/null > todo.txt
|
|
||||||
test_todo_session 'prepend handling priority and prepended date on add' <<EOF
|
|
||||||
>>> todo.sh -t add "new task"
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh pri 1 A
|
|
||||||
1 (A) 2009-02-13 new task
|
|
||||||
TODO: 1 prioritized (A).
|
|
||||||
|
|
||||||
>>> todo.sh prepend 1 "this is just a"
|
|
||||||
1 (A) 2009-02-13 this is just a new task
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat /dev/null > todo.txt
|
|
||||||
test_todo_session 'prepend with prepended date keeps both' <<EOF
|
|
||||||
>>> todo.sh -t add "new task"
|
|
||||||
1 2009-02-13 new task
|
|
||||||
TODO: 1 added.
|
|
||||||
|
|
||||||
>>> todo.sh prepend 1 "2010-07-04 this is just a"
|
|
||||||
1 2009-02-13 2010-07-04 this is just a new task
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -8,13 +8,7 @@ test_description='do functionality
|
|||||||
|
|
||||||
test_todo_session 'do usage' <<EOF
|
test_todo_session 'do usage' <<EOF
|
||||||
>>> todo.sh do B B
|
>>> todo.sh do B B
|
||||||
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
usage: todo.sh do ITEM#
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_todo_session 'do missing ITEM#' <<EOF
|
|
||||||
>>> todo.sh do
|
|
||||||
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
|
||||||
=== 1
|
=== 1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@@ -41,9 +35,9 @@ test_todo_session 'basic do' <<EOF
|
|||||||
TODO: 7 of 7 tasks shown
|
TODO: 7 of 7 tasks shown
|
||||||
|
|
||||||
>>> todo.sh do 7,6
|
>>> todo.sh do 7,6
|
||||||
7 x 2009-02-13 remove4
|
7: x 2009-02-13 remove4
|
||||||
TODO: 7 marked as done.
|
TODO: 7 marked as done.
|
||||||
6 x 2009-02-13 remove3
|
6: x 2009-02-13 remove3
|
||||||
TODO: 6 marked as done.
|
TODO: 6 marked as done.
|
||||||
x 2009-02-13 remove3
|
x 2009-02-13 remove3
|
||||||
x 2009-02-13 remove4
|
x 2009-02-13 remove4
|
||||||
@@ -59,9 +53,9 @@ TODO: $HOME/todo.txt archived.
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh do 5 4
|
>>> todo.sh do 5 4
|
||||||
5 x 2009-02-13 remove2
|
5: x 2009-02-13 remove2
|
||||||
TODO: 5 marked as done.
|
TODO: 5 marked as done.
|
||||||
4 x 2009-02-13 remove1
|
4: x 2009-02-13 remove1
|
||||||
TODO: 4 marked as done.
|
TODO: 4 marked as done.
|
||||||
x 2009-02-13 remove1
|
x 2009-02-13 remove1
|
||||||
x 2009-02-13 remove2
|
x 2009-02-13 remove2
|
||||||
@@ -77,7 +71,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'fail multiple do attempts' <<EOF
|
test_todo_session 'fail multiple do attempts' <<EOF
|
||||||
>>> todo.sh -a do 3
|
>>> todo.sh -a do 3
|
||||||
3 x 2009-02-13 stop
|
3: x 2009-02-13 stop
|
||||||
TODO: 3 marked as done.
|
TODO: 3 marked as done.
|
||||||
|
|
||||||
>>> todo.sh -a do 3
|
>>> todo.sh -a do 3
|
||||||
|
|||||||
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
|
||||||
@@ -19,7 +19,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'basic append' <<EOF
|
test_todo_session 'basic append' <<EOF
|
||||||
>>> todo.sh append 1 "smell the roses"
|
>>> todo.sh append 1 "smell the roses"
|
||||||
1 notice the daisies smell the roses
|
1: notice the daisies smell the roses
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 notice the daisies smell the roses
|
1 notice the daisies smell the roses
|
||||||
@@ -29,7 +29,7 @@ EOF
|
|||||||
|
|
||||||
test_todo_session 'basic append with &' <<EOF
|
test_todo_session 'basic append with &' <<EOF
|
||||||
>>> todo.sh append 1 "see the wasps & bees"
|
>>> todo.sh append 1 "see the wasps & bees"
|
||||||
1 notice the daisies smell the roses see the wasps & bees
|
1: notice the daisies smell the roses see the wasps & bees
|
||||||
|
|
||||||
>>> todo.sh list
|
>>> todo.sh list
|
||||||
1 notice the daisies smell the roses see the wasps & bees
|
1 notice the daisies smell the roses see the wasps & bees
|
||||||
@@ -41,36 +41,7 @@ EOF
|
|||||||
test_todo_session 'append error' << EOF
|
test_todo_session 'append error' << EOF
|
||||||
>>> todo.sh append 10 "hej!"
|
>>> todo.sh append 10 "hej!"
|
||||||
=== 1
|
=== 1
|
||||||
TODO: No task 10.
|
10: No such todo.
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
notice the daisies
|
|
||||||
EOF
|
|
||||||
test_todo_session 'append of current sentence' <<EOF
|
|
||||||
>>> todo.sh append 1 ", lilies and roses"
|
|
||||||
1 notice the daisies, lilies and roses
|
|
||||||
|
|
||||||
>>> todo.sh append 1 "; see the wasps"
|
|
||||||
1 notice the daisies, lilies and roses; see the wasps
|
|
||||||
|
|
||||||
>>> todo.sh append 1 "& bees"
|
|
||||||
1 notice the daisies, lilies and roses; see the wasps & bees
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cp todo.cfg special-delimiters.cfg
|
|
||||||
cat >> special-delimiters.cfg <<EOF
|
|
||||||
export SENTENCE_DELIMITERS='*,.:;&'
|
|
||||||
EOF
|
|
||||||
test_todo_session 'append of current sentence SENTENCE_DELIMITERS' <<EOF
|
|
||||||
>>> todo.sh -d special-delimiters.cfg append 1 "&beans"
|
|
||||||
1 notice the daisies, lilies and roses; see the wasps & bees&beans
|
|
||||||
|
|
||||||
>>> todo.sh -d special-delimiters.cfg append 1 "%foo"
|
|
||||||
1 notice the daisies, lilies and roses; see the wasps & bees&beans %foo
|
|
||||||
|
|
||||||
>>> todo.sh -d special-delimiters.cfg append 1 "*2"
|
|
||||||
1 notice the daisies, lilies and roses; see the wasps & bees&beans %foo*2
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test_description='basic depriority functionality
|
|
||||||
'
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
test_todo_session 'depriority usage' <<EOF
|
|
||||||
>>> todo.sh depri B B
|
|
||||||
usage: todo.sh depri ITEM#[, ITEM#, ITEM#, ...]
|
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_todo_session 'depriority nonexistant item' <<EOF
|
|
||||||
>>> todo.sh depri 42
|
|
||||||
TODO: No task 42.
|
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'basic depriority' <<EOF
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh depri 1
|
|
||||||
1 smell the uppercase Roses +flowers @outside
|
|
||||||
TODO: 1 deprioritized.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 smell the uppercase Roses +flowers @outside
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
(C) stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'multiple depriority' <<EOF
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
3 (C) stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh depri 3 2
|
|
||||||
3 stop
|
|
||||||
TODO: 3 deprioritized.
|
|
||||||
2 notice the sunflowers
|
|
||||||
TODO: 2 deprioritized.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
2 notice the sunflowers
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_done
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test_description='basic del functionality
|
|
||||||
'
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
test_todo_session 'del usage' <<EOF
|
|
||||||
>>> todo.sh del B
|
|
||||||
usage: todo.sh del ITEM# [TERM]
|
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_todo_session 'del nonexistant item' <<EOF
|
|
||||||
>>> todo.sh -f del 42
|
|
||||||
TODO: No task 42.
|
|
||||||
=== 1
|
|
||||||
|
|
||||||
>>> todo.sh -f del 42 Roses
|
|
||||||
TODO: No task 42.
|
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'basic del' <<EOF
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -f del 1
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
TODO: 1 deleted.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 2 of 2 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'del preserving line numbers' <<EOF
|
|
||||||
>>> todo.sh -f del 1
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
TODO: 1 deleted.
|
|
||||||
|
|
||||||
>>> todo.sh -f del 1
|
|
||||||
TODO: No task 1.
|
|
||||||
=== 1
|
|
||||||
|
|
||||||
>>> todo.sh add A new task
|
|
||||||
4 A new task
|
|
||||||
TODO: 4 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
4 A new task
|
|
||||||
3 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh -f -n del 2
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
TODO: 2 deleted.
|
|
||||||
|
|
||||||
>>> todo.sh add Another new task
|
|
||||||
3 Another new task
|
|
||||||
TODO: 3 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 A new task
|
|
||||||
3 Another new task
|
|
||||||
1 stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
(C) stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'basic del TERM' <<EOF
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
3 (C) stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh del 1 uppercase
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
TODO: Removed 'uppercase' from task.
|
|
||||||
1 (B) smell the Roses +flowers @outside
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the Roses +flowers @outside
|
|
||||||
3 (C) stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
|
|
||||||
>>> todo.sh del 1 "the Roses"
|
|
||||||
1 (B) smell the Roses +flowers @outside
|
|
||||||
TODO: Removed 'the Roses' from task.
|
|
||||||
1 (B) smell +flowers @outside
|
|
||||||
|
|
||||||
>>> todo.sh del 1 m
|
|
||||||
1 (B) smell +flowers @outside
|
|
||||||
TODO: Removed 'm' from task.
|
|
||||||
1 (B) sell +flowers @outside
|
|
||||||
|
|
||||||
>>> todo.sh del 1 @outside
|
|
||||||
1 (B) sell +flowers @outside
|
|
||||||
TODO: Removed '@outside' from task.
|
|
||||||
1 (B) sell +flowers
|
|
||||||
|
|
||||||
>>> todo.sh del 1 sell
|
|
||||||
1 (B) sell +flowers
|
|
||||||
TODO: Removed 'sell' from task.
|
|
||||||
1 (B) +flowers
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
|
||||||
(A) notice the sunflowers
|
|
||||||
(C) stop
|
|
||||||
EOF
|
|
||||||
test_todo_session 'del nonexistant TERM' <<EOF
|
|
||||||
>>> todo.sh del 1 dung
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
TODO: 'dung' not found; no removal done.
|
|
||||||
=== 1
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
|
||||||
2 (A) notice the sunflowers
|
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
|
||||||
3 (C) stop
|
|
||||||
--
|
|
||||||
TODO: 3 of 3 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_done
|
|
||||||
@@ -6,9 +6,9 @@ test_description='Multi-line functionality'
|
|||||||
|
|
||||||
## Replace test
|
## Replace test
|
||||||
# Create the expected file
|
# Create the expected file
|
||||||
echo "1 smell the cheese
|
echo "1: smell the cheese
|
||||||
TODO: Replaced task with:
|
replaced with
|
||||||
1 eat apples eat oranges drink milk">$HOME/expect.multi
|
1: eat apples eat oranges drink milk">$HOME/expect.multi
|
||||||
|
|
||||||
test_expect_success 'multiline squash item replace' '
|
test_expect_success 'multiline squash item replace' '
|
||||||
(
|
(
|
||||||
@@ -33,8 +33,7 @@ fi
|
|||||||
|
|
||||||
## Add test
|
## Add test
|
||||||
# Create the expected file
|
# Create the expected file
|
||||||
echo "2 eat apples eat oranges drink milk
|
echo "TODO: 'eat apples eat oranges drink milk' added on line 2.">$HOME/expect.multi
|
||||||
TODO: 2 added.">$HOME/expect.multi
|
|
||||||
|
|
||||||
test_expect_success 'multiline squash item add' '
|
test_expect_success 'multiline squash item add' '
|
||||||
(
|
(
|
||||||
@@ -59,7 +58,7 @@ fi
|
|||||||
|
|
||||||
## Append test
|
## Append test
|
||||||
# Create the expected file
|
# Create the expected file
|
||||||
echo "1 smell the cheese eat apples eat oranges drink milk">$HOME/expect.multi
|
echo "1: smell the cheese eat apples eat oranges drink milk">$HOME/expect.multi
|
||||||
|
|
||||||
test_expect_success 'multiline squash item append' '
|
test_expect_success 'multiline squash item append' '
|
||||||
(
|
(
|
||||||
@@ -84,7 +83,7 @@ fi
|
|||||||
|
|
||||||
## Prepend test
|
## Prepend test
|
||||||
# Create the expected file
|
# Create the expected file
|
||||||
echo "1 eat apples eat oranges drink milk smell the cheese">$HOME/expect.multi
|
echo "1: eat apples eat oranges drink milk smell the cheese">$HOME/expect.multi
|
||||||
|
|
||||||
test_expect_success 'multiline squash item prepend' '
|
test_expect_success 'multiline squash item prepend' '
|
||||||
(
|
(
|
||||||
@@ -109,12 +108,9 @@ fi
|
|||||||
|
|
||||||
## Multiple line addition
|
## Multiple line addition
|
||||||
# Create the expected file
|
# Create the expected file
|
||||||
echo "2 eat apples
|
echo "TODO: 'eat apples' added on line 2." > $HOME/expect.multi
|
||||||
TODO: 2 added." > $HOME/expect.multi
|
echo "TODO: 'eat oranges' added on line 3." >>$HOME/expect.multi
|
||||||
echo "3 eat oranges
|
echo "TODO: 'drink milk' added on line 4." >> $HOME/expect.multi
|
||||||
TODO: 3 added." >>$HOME/expect.multi
|
|
||||||
echo "4 drink milk
|
|
||||||
TODO: 4 added." >> $HOME/expect.multi
|
|
||||||
|
|
||||||
test_expect_success 'actual multiline add' '
|
test_expect_success 'actual multiline add' '
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
test_description='custom actions functionality
|
|
||||||
|
|
||||||
This test covers the contract between todo.sh and custom actions.
|
|
||||||
'
|
|
||||||
. ./test-lib.sh
|
|
||||||
|
|
||||||
unset TODO_ACTIONS_DIR
|
|
||||||
mkdir .todo.actions.d
|
|
||||||
cat > .todo.actions.d/foo << EOF
|
|
||||||
echo "TODO: foo"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_todo_session 'nonexecutable action' <<EOF
|
|
||||||
>>> todo.sh foo
|
|
||||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
|
||||||
Try 'todo.sh -h' for more information.
|
|
||||||
=== 1
|
|
||||||
EOF
|
|
||||||
|
|
||||||
chmod +x .todo.actions.d/foo
|
|
||||||
test_todo_session 'executable action' <<EOF
|
|
||||||
>>> todo.sh foo
|
|
||||||
TODO: foo
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > .todo.actions.d/ls << EOF
|
|
||||||
echo "TODO: my ls"
|
|
||||||
EOF
|
|
||||||
chmod +x .todo.actions.d/ls
|
|
||||||
test_todo_session 'overriding built-in action' <<EOF
|
|
||||||
>>> todo.sh ls
|
|
||||||
TODO: my ls
|
|
||||||
|
|
||||||
>>> todo.sh command ls
|
|
||||||
--
|
|
||||||
TODO: 0 of 0 tasks shown
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > .todo.actions.d/bad << EOF
|
|
||||||
echo "TODO: bad"
|
|
||||||
exit 42
|
|
||||||
EOF
|
|
||||||
chmod +x .todo.actions.d/bad
|
|
||||||
test_todo_session 'failing action' <<EOF
|
|
||||||
>>> todo.sh bad
|
|
||||||
TODO: bad
|
|
||||||
=== 42
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test_done
|
|
||||||
@@ -36,7 +36,7 @@ TODO: 2 of 4 tasks shown
|
|||||||
TODO: 1 of 4 tasks shown
|
TODO: 1 of 4 tasks shown
|
||||||
|
|
||||||
>>> todo.sh -a do 2
|
>>> todo.sh -a do 2
|
||||||
2 x 2009-02-13 notice the sunflowers
|
2: x 2009-02-13 notice the sunflowers
|
||||||
TODO: 2 marked as done.
|
TODO: 2 marked as done.
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -48,8 +48,7 @@ TODO: 2 marked as done.
|
|||||||
TODO: 4 of 4 tasks shown
|
TODO: 4 of 4 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add "make the coffee +wakeup"
|
>>> todo.sh add "make the coffee +wakeup"
|
||||||
5 make the coffee +wakeup
|
TODO: 'make the coffee +wakeup' added on line 5.
|
||||||
TODO: 5 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list coffee
|
>>> todo.sh -p list coffee
|
||||||
5 make the coffee +wakeup
|
5 make the coffee +wakeup
|
||||||
@@ -58,8 +57,7 @@ TODO: 5 added.
|
|||||||
TODO: 2 of 5 tasks shown
|
TODO: 2 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add "visit http://example.com"
|
>>> todo.sh add "visit http://example.com"
|
||||||
6 visit http://example.com
|
TODO: 'visit http://example.com' added on line 6.
|
||||||
TODO: 6 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
@@ -98,7 +96,7 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
|||||||
=== 1
|
=== 1
|
||||||
|
|
||||||
>>> todo.sh append 2 and think
|
>>> todo.sh append 2 and think
|
||||||
2 stop and think
|
2: stop and think
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
@@ -110,7 +108,7 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh append 10 "hej!"
|
>>> todo.sh append 10 "hej!"
|
||||||
TODO: No task 10.
|
10: No such todo.
|
||||||
=== 1
|
=== 1
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -123,7 +121,7 @@ TODO: No task 10.
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh do 10
|
>>> todo.sh do 10
|
||||||
TODO: No task 10.
|
10: No such todo.
|
||||||
=== 1
|
=== 1
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -136,8 +134,7 @@ TODO: No task 10.
|
|||||||
TODO: 5 of 5 tasks shown
|
TODO: 5 of 5 tasks shown
|
||||||
|
|
||||||
>>> todo.sh add "the coffee +wakeup"
|
>>> todo.sh add "the coffee +wakeup"
|
||||||
6 the coffee +wakeup
|
TODO: 'the coffee +wakeup' added on line 6.
|
||||||
TODO: 6 added.
|
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
@@ -150,7 +147,7 @@ TODO: 6 added.
|
|||||||
TODO: 6 of 6 tasks shown
|
TODO: 6 of 6 tasks shown
|
||||||
|
|
||||||
>>> todo.sh prepend 6 "make"
|
>>> todo.sh prepend 6 "make"
|
||||||
6 make the coffee +wakeup
|
6: make the coffee +wakeup
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ test_todo_session () {
|
|||||||
if [ $status = 0 ]; then
|
if [ $status = 0 ]; then
|
||||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||||
else
|
else
|
||||||
test_expect_success "$1 $subnum" "$cmd > output ; test \$? = $status && test_cmp expect output"
|
test_expect_success "$1 $subnum" "$cmd > output || test $? = $status && test_cmp expect output"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
subnum=$(($subnum + 1))
|
subnum=$(($subnum + 1))
|
||||||
@@ -560,7 +560,7 @@ test_todo_session () {
|
|||||||
if [ $status = 0 ]; then
|
if [ $status = 0 ]; then
|
||||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||||
else
|
else
|
||||||
test_expect_success "$1 $subnum" "$cmd > output ; test \$? = $status && test_cmp expect output"
|
test_expect_success "$1 $subnum" "$cmd > output || test $? = $status && test_cmp expect output"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
26
todo.cfg
26
todo.cfg
@@ -17,13 +17,8 @@ export TMP_FILE="$TODO_DIR/todo.tmp"
|
|||||||
|
|
||||||
# === COLOR MAP ===
|
# === COLOR MAP ===
|
||||||
|
|
||||||
## Text coloring and formatting is done by inserting ANSI escape codes.
|
## If you have re-mapped your color codes, you may need to
|
||||||
## If you have re-mapped your color codes, or use the todo.txt
|
|
||||||
## output in another output system (like Conky), you may need to
|
|
||||||
## over-ride by uncommenting and editing these defaults.
|
## over-ride by uncommenting and editing these defaults.
|
||||||
## If you change any of these here, you also need to uncomment
|
|
||||||
## the defaults in the COLORS section below. Otherwise, todo.txt
|
|
||||||
## will still use the defaults!
|
|
||||||
|
|
||||||
# export BLACK='\\033[0;30m'
|
# export BLACK='\\033[0;30m'
|
||||||
# export RED='\\033[0;31m'
|
# export RED='\\033[0;31m'
|
||||||
@@ -43,25 +38,16 @@ export TMP_FILE="$TODO_DIR/todo.tmp"
|
|||||||
# export WHITE='\\033[1;37m'
|
# export WHITE='\\033[1;37m'
|
||||||
# export DEFAULT='\\033[0m'
|
# export DEFAULT='\\033[0m'
|
||||||
|
|
||||||
# === COLORS ===
|
# === PRIORITY COLORS ===
|
||||||
|
|
||||||
|
## Priorities can be any upper-case letter.
|
||||||
|
## Colors are supported for the first three.
|
||||||
## Uncomment and edit to override these defaults.
|
## Uncomment and edit to override these defaults.
|
||||||
## Reference the constants from the color map above,
|
|
||||||
## or use $NONE to disable highlighting.
|
|
||||||
#
|
|
||||||
# Priorities can be any upper-case letter.
|
|
||||||
# A,B,C are highlighted; you can add coloring for more.
|
|
||||||
#
|
|
||||||
# export PRI_A=$YELLOW # color for A priority
|
# export PRI_A=$YELLOW # color for A priority
|
||||||
# export PRI_B=$GREEN # color for B priority
|
# export PRI_B=$GREEN # color for B priority
|
||||||
# export PRI_C=$LIGHT_BLUE # color for C priority
|
# export PRI_C=$LIGHT_BLUE # color for C priority
|
||||||
# export PRI_D=... # define your own
|
# export PRI_X=$WHITE # color for rest of them
|
||||||
# export PRI_X=$WHITE # color unless explicitly defined
|
|
||||||
|
|
||||||
# There is highlighting for tasks that have been done,
|
|
||||||
# but haven't been archived yet.
|
|
||||||
#
|
|
||||||
# export COLOR_DONE=$LIGHT_GREY
|
|
||||||
|
|
||||||
# === BEHAVIOR ===
|
# === BEHAVIOR ===
|
||||||
|
|
||||||
|
|||||||
629
todo.sh
629
todo.sh
@@ -1,8 +1,5 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# === HEAVY LIFTING ===
|
|
||||||
shopt -s extglob
|
|
||||||
|
|
||||||
# NOTE: Todo.sh requires the .todo/config configuration file to run.
|
# NOTE: Todo.sh requires the .todo/config configuration file to run.
|
||||||
# Place the .todo/config file in your home directory or use the -d option for a custom location.
|
# Place the .todo/config file in your home directory or use the -d option for a custom location.
|
||||||
|
|
||||||
@@ -47,12 +44,12 @@ shorthelp()
|
|||||||
addto DEST "TEXT TO ADD"
|
addto DEST "TEXT TO ADD"
|
||||||
addm "THINGS I NEED TO DO
|
addm "THINGS I NEED TO DO
|
||||||
MORE THINGS I NEED TO DO"
|
MORE THINGS I NEED TO DO"
|
||||||
append|app ITEM# "TEXT TO APPEND"
|
append|app NUMBER "TEXT TO APPEND"
|
||||||
archive
|
archive
|
||||||
command [ACTIONS]
|
command [ACTIONS]
|
||||||
del|rm ITEM# [TERM]
|
del|rm NUMBER [TERM]
|
||||||
dp|depri ITEM#[, ITEM#, ITEM#, ...]
|
dp|depri NUMBER
|
||||||
do ITEM#[, ITEM#, ITEM#, ...]
|
do NUMBER
|
||||||
help
|
help
|
||||||
list|ls [TERM...]
|
list|ls [TERM...]
|
||||||
listall|lsa [TERM...]
|
listall|lsa [TERM...]
|
||||||
@@ -60,10 +57,10 @@ shorthelp()
|
|||||||
listfile|lf SRC [TERM...]
|
listfile|lf SRC [TERM...]
|
||||||
listpri|lsp [PRIORITY]
|
listpri|lsp [PRIORITY]
|
||||||
listproj|lsprj
|
listproj|lsprj
|
||||||
move|mv ITEM# DEST [SRC]
|
move|mv NUMBER DEST [SRC]
|
||||||
prepend|prep ITEM# "TEXT TO PREPEND"
|
prepend|prep NUMBER "TEXT TO PREPEND"
|
||||||
pri|p ITEM# PRIORITY
|
pri|p NUMBER PRIORITY
|
||||||
replace ITEM# "UPDATED TODO"
|
replace NUMBER "UPDATED TODO"
|
||||||
report
|
report
|
||||||
|
|
||||||
See "help" for more details.
|
See "help" for more details.
|
||||||
@@ -94,37 +91,37 @@ help()
|
|||||||
Adds a line of text to any file located in the todo.txt directory.
|
Adds a line of text to any file located in the todo.txt directory.
|
||||||
For example, addto inbox.txt "decide about vacation"
|
For example, addto inbox.txt "decide about vacation"
|
||||||
|
|
||||||
append ITEM# "TEXT TO APPEND"
|
append NUMBER "TEXT TO APPEND"
|
||||||
app ITEM# "TEXT TO APPEND"
|
app NUMBER "TEXT TO APPEND"
|
||||||
Adds TEXT TO APPEND to the end of the task on line ITEM#.
|
Adds TEXT TO APPEND to the end of the todo on line NUMBER.
|
||||||
Quotes optional.
|
Quotes optional.
|
||||||
|
|
||||||
archive
|
archive
|
||||||
Moves all done tasks from todo.txt to done.txt and removes blank lines.
|
Moves done items from todo.txt to done.txt and removes blank lines.
|
||||||
|
|
||||||
command [ACTIONS]
|
command [ACTIONS]
|
||||||
Runs the remaining arguments using only todo.sh builtins.
|
Runs the remaining arguments using only todo.sh builtins.
|
||||||
Will not call any .todo.actions.d scripts.
|
Will not call any .todo.actions.d scripts.
|
||||||
|
|
||||||
del ITEM# [TERM]
|
del NUMBER [TERM]
|
||||||
rm ITEM# [TERM]
|
rm NUMBER [TERM]
|
||||||
Deletes the task on line ITEM# in todo.txt.
|
Deletes the item on line NUMBER in todo.txt.
|
||||||
If TERM specified, deletes only TERM from the task.
|
If term specified, deletes only the term from the line.
|
||||||
|
|
||||||
depri ITEM#[, ITEM#, ITEM#, ...]
|
depri NUMBER
|
||||||
dp ITEM#[, ITEM#, ITEM#, ...]
|
dp NUMBER
|
||||||
Deprioritizes (removes the priority) from the task(s)
|
Deprioritizes (removes the priority) from the item
|
||||||
on line ITEM# in todo.txt.
|
on line NUMBER in todo.txt.
|
||||||
|
|
||||||
do ITEM#[, ITEM#, ITEM#, ...]
|
do NUMBER[, NUMBER, NUMBER, ...]
|
||||||
Marks task(s) on line ITEM# as done in todo.txt.
|
Marks item(s) on line NUMBER as done in todo.txt.
|
||||||
|
|
||||||
help
|
help
|
||||||
Display this help message.
|
Display this help message.
|
||||||
|
|
||||||
list [TERM...]
|
list [TERM...]
|
||||||
ls [TERM...]
|
ls [TERM...]
|
||||||
Displays all tasks that contain TERM(s) sorted by priority with line
|
Displays all todo's that contain TERM(s) sorted by priority with line
|
||||||
numbers. If no TERM specified, lists entire todo.txt.
|
numbers. If no TERM specified, lists entire todo.txt.
|
||||||
|
|
||||||
listall [TERM...]
|
listall [TERM...]
|
||||||
@@ -145,36 +142,36 @@ help()
|
|||||||
|
|
||||||
listpri [PRIORITY]
|
listpri [PRIORITY]
|
||||||
lsp [PRIORITY]
|
lsp [PRIORITY]
|
||||||
Displays all tasks prioritized PRIORITY.
|
Displays all items prioritized PRIORITY.
|
||||||
If no PRIORITY specified, lists all prioritized tasks.
|
If no PRIORITY specified, lists all prioritized items.
|
||||||
|
|
||||||
listproj
|
listproj
|
||||||
lsprj
|
lsprj
|
||||||
Lists all the projects that start with the + sign in todo.txt.
|
Lists all the projects that start with the + sign in todo.txt.
|
||||||
|
|
||||||
move ITEM# DEST [SRC]
|
move NUMBER DEST [SRC]
|
||||||
mv ITEM# DEST [SRC]
|
mv NUMBER DEST [SRC]
|
||||||
Moves a line from source text file (SRC) to destination text file (DEST).
|
Moves a line from source text file (SRC) to destination text file (DEST).
|
||||||
Both source and destination file must be located in the directory defined
|
Both source and destination file must be located in the directory defined
|
||||||
in the configuration directory. When SRC is not defined
|
in the configuration directory. When SRC is not defined
|
||||||
it's by default todo.txt.
|
it's by default todo.txt.
|
||||||
|
|
||||||
prepend ITEM# "TEXT TO PREPEND"
|
prepend NUMBER "TEXT TO PREPEND"
|
||||||
prep ITEM# "TEXT TO PREPEND"
|
prep NUMBER "TEXT TO PREPEND"
|
||||||
Adds TEXT TO PREPEND to the beginning of the task on line ITEM#.
|
Adds TEXT TO PREPEND to the beginning of the todo on line NUMBER.
|
||||||
Quotes optional.
|
Quotes optional.
|
||||||
|
|
||||||
pri ITEM# PRIORITY
|
pri NUMBER PRIORITY
|
||||||
p ITEM# PRIORITY
|
p NUMBER PRIORITY
|
||||||
Adds PRIORITY to task on line ITEM#. If the task is already
|
Adds PRIORITY to todo on line NUMBER. If the item is already
|
||||||
prioritized, replaces current priority with new PRIORITY.
|
prioritized, replaces current priority with new PRIORITY.
|
||||||
PRIORITY must be an uppercase letter between A and Z.
|
PRIORITY must be an uppercase letter between A and Z.
|
||||||
|
|
||||||
replace ITEM# "UPDATED TODO"
|
replace NUMBER "UPDATED TODO"
|
||||||
Replaces task on line ITEM# with UPDATED TODO.
|
Replaces todo on line NUMBER with UPDATED TODO.
|
||||||
|
|
||||||
report
|
report
|
||||||
Adds the number of open tasks and done tasks to report.txt.
|
Adds the number of open todo's and closed done's to report.txt.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -253,7 +250,7 @@ die()
|
|||||||
cleanup()
|
cleanup()
|
||||||
{
|
{
|
||||||
[ -f "$TMP_FILE" ] && rm "$TMP_FILE"
|
[ -f "$TMP_FILE" ] && rm "$TMP_FILE"
|
||||||
return 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
cleaninput()
|
cleaninput()
|
||||||
@@ -280,68 +277,13 @@ archive()
|
|||||||
sed -i.bak '/^x /d' "$TODO_FILE"
|
sed -i.bak '/^x /d' "$TODO_FILE"
|
||||||
cp "$TODO_FILE" "$TMP_FILE"
|
cp "$TODO_FILE" "$TMP_FILE"
|
||||||
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
#[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed."
|
||||||
echo "TODO: $TODO_FILE archived."
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived."
|
||||||
fi
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
|
_commit "TODO: $TODO_FILE archived." $TODO_FILE $DONE_FILE
|
||||||
|
cleanup
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceOrPrepend()
|
|
||||||
{
|
|
||||||
action=$1; shift
|
|
||||||
case "$action" in
|
|
||||||
replace)
|
|
||||||
backref=
|
|
||||||
querytext="Replacement: "
|
|
||||||
;;
|
|
||||||
prepend)
|
|
||||||
backref=' &'
|
|
||||||
querytext="Prepend: "
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift; item=$1; shift
|
|
||||||
|
|
||||||
[ -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
|
|
||||||
echo -n "$querytext"
|
|
||||||
read input
|
|
||||||
else
|
|
||||||
input=$*
|
|
||||||
fi
|
|
||||||
cleaninput $input
|
|
||||||
|
|
||||||
# Retrieve existing priority and prepended date
|
|
||||||
priority=$(sed -e "$item!d" -e $item's/^\(([A-Z]) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\1/' "$TODO_FILE")
|
|
||||||
prepdate=$(sed -e "$item!d" -e $item's/^\(([A-Z]) \)\{0,1\}\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{0,1\}.*/\2/' "$TODO_FILE")
|
|
||||||
|
|
||||||
if [ "$prepdate" -a "$action" = "replace" ] && [ "$(echo "$input"|sed -e 's/^\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\}\)\{0,1\}.*/\1/')" ]; then
|
|
||||||
# If the replaced text starts with a date, it will replace the existing
|
|
||||||
# date, too.
|
|
||||||
prepdate=
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Temporarily remove any existing priority and prepended date, perform the
|
|
||||||
# change (replace/prepend) and re-insert the existing priority and prepended
|
|
||||||
# date again.
|
|
||||||
sed -i.bak -e "$item s/^${priority}${prepdate}//" -e "$item s|^.*|${priority}${prepdate}${input}${backref}|" "$TODO_FILE"
|
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
|
||||||
case "$action" in
|
|
||||||
replace)
|
|
||||||
echo "$item $todo"
|
|
||||||
echo "TODO: Replaced task with:"
|
|
||||||
echo "$item $newtodo"
|
|
||||||
;;
|
|
||||||
prepend)
|
|
||||||
echo "$item $newtodo"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# == PROCESS OPTIONS ==
|
# == PROCESS OPTIONS ==
|
||||||
while getopts ":fhpnatvVx+@Pd:" Option
|
while getopts ":fhpnatvVx+@Pd:" Option
|
||||||
@@ -440,6 +382,8 @@ TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
|||||||
TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-}
|
TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-}
|
||||||
TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2}
|
TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2}
|
||||||
TODOTXT_FINAL_FILTER=${TODOTXT_FINAL_FILTER:-cat}
|
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 all TODOTXT_* variables
|
||||||
export ${!TODOTXT_@}
|
export ${!TODOTXT_@}
|
||||||
@@ -468,16 +412,7 @@ export DEFAULT='\\033[0m'
|
|||||||
export PRI_A=$YELLOW # color for A priority
|
export PRI_A=$YELLOW # color for A priority
|
||||||
export PRI_B=$GREEN # color for B priority
|
export PRI_B=$GREEN # color for B priority
|
||||||
export PRI_C=$LIGHT_BLUE # color for C priority
|
export PRI_C=$LIGHT_BLUE # color for C priority
|
||||||
export PRI_X=$WHITE # color unless explicitly defined
|
export PRI_X=$WHITE # color for rest of them
|
||||||
|
|
||||||
# Default highlight colors.
|
|
||||||
export COLOR_DONE=$LIGHT_GREY # color for done (but not yet archived) tasks
|
|
||||||
|
|
||||||
# Default sentence delimiters for todo.sh append.
|
|
||||||
# If the text to be appended to the task begins with one of these characters, no
|
|
||||||
# whitespace is inserted in between. This makes appending to an enumeration
|
|
||||||
# (todo.sh add 42 ", foo") syntactically correct.
|
|
||||||
export SENTENCE_DELIMITERS=',.:;'
|
|
||||||
|
|
||||||
[ -e "$TODOTXT_CFG_FILE" ] || {
|
[ -e "$TODOTXT_CFG_FILE" ] || {
|
||||||
CFG_FILE_ALT="$HOME/todo.cfg"
|
CFG_FILE_ALT="$HOME/todo.cfg"
|
||||||
@@ -513,7 +448,7 @@ fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
# === SANITY CHECKS (thanks Karl!) ===
|
# === SANITY CHECKS (thanks Karl!) ===
|
||||||
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal Error: Cannot read configuration file $TODOTXT_CFG_FILE"
|
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE"
|
||||||
|
|
||||||
. "$TODOTXT_CFG_FILE"
|
. "$TODOTXT_CFG_FILE"
|
||||||
|
|
||||||
@@ -529,14 +464,16 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|
|||||||
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
||||||
|
|
||||||
if [ $TODOTXT_PLAIN = 1 ]; then
|
if [ $TODOTXT_PLAIN = 1 ]; then
|
||||||
for clr in ${!PRI_@}; do
|
PRI_A=$NONE
|
||||||
export $clr=$NONE
|
PRI_B=$NONE
|
||||||
done
|
PRI_C=$NONE
|
||||||
PRI_X=$NONE
|
PRI_X=$NONE
|
||||||
DEFAULT=$NONE
|
DEFAULT=$NONE
|
||||||
COLOR_DONE=$NONE
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# === HEAVY LIFTING ===
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
_addto() {
|
_addto() {
|
||||||
file="$1"
|
file="$1"
|
||||||
input="$2"
|
input="$2"
|
||||||
@@ -547,33 +484,69 @@ _addto() {
|
|||||||
input="$now $input"
|
input="$now $input"
|
||||||
fi
|
fi
|
||||||
echo "$input" >> "$file"
|
echo "$input" >> "$file"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
|
||||||
|
( [ $TODOTXT_VERBOSE -gt 0 ] || [ $TODOTXT_GIT_ENABLED -eq 1 ] ) && {
|
||||||
TASKNUM=$(sed -n '$ =' "$file")
|
TASKNUM=$(sed -n '$ =' "$file")
|
||||||
BASE=$(basename "$file")
|
BASE=$(basename "$file")
|
||||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||||
echo "$TASKNUM $input"
|
MESG="${PREFIX}: '$input' added on line $TASKNUM."
|
||||||
echo "${PREFIX}: $TASKNUM added."
|
[ $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
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_list() {
|
_list() {
|
||||||
local FILE="$1"
|
local FILE="$1"
|
||||||
## If the file starts with a "/" use absolute path. Otherwise,
|
## If the file starts with a "/" use absolute path. Otherwise,
|
||||||
## try to find it in either $TODO_DIR or using a relative path
|
## try to find it in either $TODO_DIR or using a relative path
|
||||||
if [ "${1:0:1}" == / ]; then
|
if [ "${1:0:1}" == / ]
|
||||||
|
then
|
||||||
## Absolute path
|
## Absolute path
|
||||||
src="$FILE"
|
src="$FILE"
|
||||||
elif [ -f "$TODO_DIR/$FILE" ]; then
|
elif [ -f "$TODO_DIR/$FILE" ]
|
||||||
|
then
|
||||||
## Path relative to todo.sh directory
|
## Path relative to todo.sh directory
|
||||||
src="$TODO_DIR/$FILE"
|
src="$TODO_DIR/$1"
|
||||||
elif [ -f "$FILE" ]; then
|
elif [ -f "$FILE" ]
|
||||||
|
then
|
||||||
## Path relative to current working directory
|
## Path relative to current working directory
|
||||||
src="$FILE"
|
src="$FILE"
|
||||||
elif [ -f "$TODO_DIR/${FILE}.txt" ]; then
|
|
||||||
## Path relative to todo.sh directory, missing file extension
|
|
||||||
src="$TODO_DIR/${FILE}.txt"
|
|
||||||
else
|
else
|
||||||
die "TODO: File $FILE does not exist."
|
echo "TODO: File $FILE does not exist."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Get our search arguments, if any
|
## Get our search arguments, if any
|
||||||
@@ -582,10 +555,10 @@ _list() {
|
|||||||
## Prefix the filter_command with the pre_filter_command
|
## Prefix the filter_command with the pre_filter_command
|
||||||
filter_command="${pre_filter_command:-}"
|
filter_command="${pre_filter_command:-}"
|
||||||
|
|
||||||
for search_term
|
for search_term in "$@"
|
||||||
do
|
do
|
||||||
## See if the first character of $search_term is a dash
|
## See if the first character of $search_term is a dash
|
||||||
if [ "${search_term:0:1}" != '-' ]
|
if [ ${search_term:0:1} != '-' ]
|
||||||
then
|
then
|
||||||
## First character isn't a dash: hide lines that don't match
|
## First character isn't a dash: hide lines that don't match
|
||||||
## this $search_term
|
## this $search_term
|
||||||
@@ -637,16 +610,13 @@ _list() {
|
|||||||
''' \
|
''' \
|
||||||
| eval ${TODOTXT_SORT_COMMAND} \
|
| eval ${TODOTXT_SORT_COMMAND} \
|
||||||
| sed '''
|
| sed '''
|
||||||
/^[0-9]\{'$PADDING'\} x /s|^.*|'$COLOR_DONE'&'$DEFAULT'|
|
/^[0-9]\{'$PADDING'\} x /! {
|
||||||
''' \
|
s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g;
|
||||||
| awk '''{
|
s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g;
|
||||||
pos = match($0, /\([A-Z]\)/)
|
s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g;
|
||||||
if( pos > 0 && match($0, /^[0-9]+ x /) != 1 ) {
|
s/\(.*([D-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g;
|
||||||
clr=ENVIRON["PRI_" substr($0, pos+1, 1)]
|
}
|
||||||
str = ( clr ? clr : ENVIRON["PRI_X"] ) $0 ENVIRON["DEFAULT"]
|
''' \
|
||||||
gsub( /\\+033/, "\033", str) ; print str
|
|
||||||
} else { print }
|
|
||||||
}''' \
|
|
||||||
| sed '''
|
| sed '''
|
||||||
s/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g
|
s/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g
|
||||||
s/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g
|
s/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g
|
||||||
@@ -665,12 +635,13 @@ _list() {
|
|||||||
echo "--"
|
echo "--"
|
||||||
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"
|
echo "${PREFIX}: ${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 _list die
|
export -f _list
|
||||||
|
|
||||||
# == HANDLE ACTION ==
|
# == HANDLE ACTION ==
|
||||||
action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' )
|
action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' )
|
||||||
@@ -688,9 +659,7 @@ then
|
|||||||
elif [ -d "$TODO_ACTIONS_DIR" -a -x "$TODO_ACTIONS_DIR/$action" ]
|
elif [ -d "$TODO_ACTIONS_DIR" -a -x "$TODO_ACTIONS_DIR/$action" ]
|
||||||
then
|
then
|
||||||
"$TODO_ACTIONS_DIR/$action" "$@"
|
"$TODO_ACTIONS_DIR/$action" "$@"
|
||||||
status=$?
|
|
||||||
cleanup
|
cleanup
|
||||||
exit $status
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Only run if $action isn't found in .todo.actions.d
|
## Only run if $action isn't found in .todo.actions.d
|
||||||
@@ -705,7 +674,7 @@ case $action in
|
|||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
_addto "$TODO_FILE" "$input"
|
_addto "$TODO_FILE" "$input"
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
"addm")
|
"addm")
|
||||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
@@ -727,7 +696,7 @@ case $action in
|
|||||||
_addto "$TODO_FILE" "$line"
|
_addto "$TODO_FILE" "$line"
|
||||||
done
|
done
|
||||||
IFS=$SAVEIFS
|
IFS=$SAVEIFS
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
"addto" )
|
"addto" )
|
||||||
[ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\""
|
[ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\""
|
||||||
@@ -740,9 +709,9 @@ case $action in
|
|||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
_addto "$dest" "$input"
|
_addto "$dest" "$input"
|
||||||
else
|
else
|
||||||
die "TODO: Destination file $dest does not exist."
|
echo "TODO: Destination file $dest does not exist."
|
||||||
fi
|
fi
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
"append" | "app" )
|
"append" | "app" )
|
||||||
errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\""
|
errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\""
|
||||||
@@ -751,126 +720,121 @@ case $action in
|
|||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "TODO: No task $item."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Append: "
|
echo -n "Append: "
|
||||||
read input
|
read input
|
||||||
else
|
else
|
||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
case "$input" in
|
|
||||||
[$SENTENCE_DELIMITERS]*) appendspace=;;
|
|
||||||
*) appendspace=" ";;
|
|
||||||
esac
|
|
||||||
cleaninput $input
|
cleaninput $input
|
||||||
|
|
||||||
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
|
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item $newtodo"
|
echo "$item: $newtodo"
|
||||||
fi
|
}
|
||||||
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
|
_commit "TODO: Appended '$todo' w/ '$input' on line $item." \
|
||||||
|
$TODO_FILE
|
||||||
else
|
else
|
||||||
die "TODO: Error appending task $item."
|
echo "TODO: Error appending task $item."
|
||||||
fi
|
fi
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
"archive" )
|
"archive" )
|
||||||
archive;;
|
archive;;
|
||||||
|
|
||||||
|
"commit" )
|
||||||
|
[ -z "$2" ] && die "usage: $TODO_SH commit MESSAGE"
|
||||||
|
shift
|
||||||
|
MESG=$*
|
||||||
|
|
||||||
|
( cd $TODO_DIR
|
||||||
|
git commit -a -m "$MESG"
|
||||||
|
);;
|
||||||
|
|
||||||
"del" | "rm" )
|
"del" | "rm" )
|
||||||
# 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#"
|
||||||
item=$2
|
item=$2
|
||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$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
|
|
||||||
echo "Delete '$DELETEME'? (y/n)"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
read ANSWER
|
if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
|
||||||
else
|
DELETEME=$(sed "$item!d" "$TODO_FILE")
|
||||||
ANSWER="y"
|
|
||||||
fi
|
if [ $TODOTXT_FORCE = 0 ]; then
|
||||||
if [ "$ANSWER" = "y" ]; then
|
echo "Delete '$DELETEME'? (y/n)"
|
||||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
read ANSWER
|
||||||
# delete line (changes line numbers)
|
|
||||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE"
|
|
||||||
else
|
else
|
||||||
# leave blank line behind (preserves line numbers)
|
ANSWER="y"
|
||||||
sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
|
|
||||||
fi
|
fi
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
if [ "$ANSWER" = "y" ]; then
|
||||||
echo "$item $DELETEME"
|
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||||
echo "TODO: $item deleted."
|
# delete line (changes line numbers)
|
||||||
|
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE"
|
||||||
|
else
|
||||||
|
# leave blank line behind (preserves line numbers)
|
||||||
|
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."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "TODO: No tasks were deleted."
|
echo "$item: No such todo."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
sed -i.bak \
|
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
||||||
-e $item"s/^\((.) \)\{0,1\} *$3 */\1/g" \
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item."
|
||||||
-e $item"s/ *$3 *\$//g" \
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
-e $item"s/ *$3 */ /g" \
|
_commit "TODO: $3 removed from $item." $TODO_FILE
|
||||||
-e $item"s/ *$3 */ /g" \
|
fi ;;
|
||||||
-e $item"s/$3//g" \
|
|
||||||
"$TODO_FILE"
|
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
|
||||||
if [ "$DELETEME" = "$newtodo" ]; then
|
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item $DELETEME"
|
|
||||||
die "TODO: '$3' not found; no removal done."
|
|
||||||
fi
|
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
|
||||||
echo "$item $DELETEME"
|
|
||||||
echo "TODO: Removed '$3' from task."
|
|
||||||
echo "$item $newtodo"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
"depri" | "dp" )
|
"depri" | "dp" )
|
||||||
errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]"
|
item=$2
|
||||||
shift;
|
errmsg="usage: $TODO_SH depri ITEM#"
|
||||||
[ $# -eq 0 ] && die "$errmsg"
|
|
||||||
|
|
||||||
# Split multiple depri's, if comma separated change to whitespace separated
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
# Loop the 'depri' function for each item
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
for item in `echo $* | tr ',' ' '`; do
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
|
||||||
[ -z "$todo" ] && die "TODO: No task $item."
|
|
||||||
|
|
||||||
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1
|
||||||
|
|
||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
#it's all good, continue
|
#it's all good, continue
|
||||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item $NEWTODO"
|
echo "`echo "$item: $NEWTODO"`"
|
||||||
echo "TODO: $item deprioritized."
|
echo "TODO: $item deprioritized."
|
||||||
fi
|
}
|
||||||
else
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
die "$errmsg"
|
_commit "TODO: '$todo' deprioritized." $TODO_FILE
|
||||||
fi
|
cleanup
|
||||||
done
|
else
|
||||||
;;
|
die "$errmsg"
|
||||||
|
fi;;
|
||||||
|
|
||||||
"do" )
|
"do" )
|
||||||
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
errmsg="usage: $TODO_SH do ITEM#"
|
||||||
# shift so we get arguments to the do request
|
# shift so we get arguments to the do request
|
||||||
shift;
|
shift;
|
||||||
[ "$#" -eq 0 ] && die "$errmsg"
|
|
||||||
|
|
||||||
# Split multiple do's, if comma separated change to whitespace separated
|
# Split multiple do's, if comma seperated change to whitespace sepereated
|
||||||
# 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"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "TODO: No task $item."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
# Check if this item has already been done
|
# Check if this item has already been done
|
||||||
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
||||||
@@ -878,11 +842,13 @@ case $action in
|
|||||||
# remove priority once item is done
|
# remove priority once item is done
|
||||||
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
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item $newtodo"
|
echo "$item: $newtodo"
|
||||||
echo "TODO: $item marked as done."
|
echo "TODO: $item marked as done."
|
||||||
fi
|
}
|
||||||
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
|
_commit "TODO: '$todo' marked as done." $TODO_FILE
|
||||||
else
|
else
|
||||||
echo "$item is already marked done"
|
echo "$item is already marked done"
|
||||||
fi
|
fi
|
||||||
@@ -891,13 +857,35 @@ case $action in
|
|||||||
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
||||||
archive
|
archive
|
||||||
fi
|
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" )
|
"help" )
|
||||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
if [ -t 1 ] ; then # STDOUT is a TTY
|
||||||
if which "${PAGER:-less}" >/dev/null 2>&1; then
|
if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then
|
||||||
# we have a working PAGER (or less as a default)
|
# we have a working PAGER (or less as a default)
|
||||||
help | "${PAGER:-less}" && exit 0
|
help | exec ${PAGER:-less}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
help # just in case something failed above, we go ahead and just spew to STDOUT
|
help # just in case something failed above, we go ahead and just spew to STDOUT
|
||||||
@@ -906,6 +894,8 @@ case $action in
|
|||||||
"list" | "ls" )
|
"list" | "ls" )
|
||||||
shift ## Was ls; new $1 is first search term
|
shift ## Was ls; new $1 is first search term
|
||||||
_list "$TODO_FILE" "$@"
|
_list "$TODO_FILE" "$@"
|
||||||
|
|
||||||
|
cleanup
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"listall" | "lsa" )
|
"listall" | "lsa" )
|
||||||
@@ -913,6 +903,8 @@ case $action in
|
|||||||
|
|
||||||
cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
|
cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
|
||||||
_list "$TMP_FILE" "$@"
|
_list "$TMP_FILE" "$@"
|
||||||
|
|
||||||
|
cleanup
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"listfile" | "lf" )
|
"listfile" | "lf" )
|
||||||
@@ -921,15 +913,18 @@ case $action in
|
|||||||
shift ## Was filename; next $1 is first search term
|
shift ## Was filename; next $1 is first search term
|
||||||
|
|
||||||
_list "$FILE" "$@"
|
_list "$FILE" "$@"
|
||||||
|
|
||||||
|
cleanup
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"listcon" | "lsc" )
|
"listcon" | "lsc" )
|
||||||
grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u
|
grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u
|
||||||
;;
|
cleanup ;;
|
||||||
|
|
||||||
"listproj" | "lsprj" )
|
"listproj" | "lsprj" )
|
||||||
grep -o '[^ ]*+[^ ]\+' "$TODO_FILE" | grep '^+' | sort -u
|
grep -o '[^ ]*+[^ ]\+' "$TODO_FILE" | grep '^+' | sort -u
|
||||||
;;
|
cleanup ;;
|
||||||
|
|
||||||
|
|
||||||
"listpri" | "lsp" )
|
"listpri" | "lsp" )
|
||||||
shift ## was "listpri", new $1 is priority to list
|
shift ## was "listpri", new $1 is priority to list
|
||||||
@@ -950,6 +945,11 @@ case $action in
|
|||||||
_list "$TODO_FILE" "$pri"
|
_list "$TODO_FILE" "$pri"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"log" | "pull" | "push" )
|
||||||
|
( cd $TODO_DIR
|
||||||
|
git $action
|
||||||
|
);;
|
||||||
|
|
||||||
"move" | "mv" )
|
"move" | "mv" )
|
||||||
# replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
# replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||||
errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]"
|
errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]"
|
||||||
@@ -963,40 +963,96 @@ case $action in
|
|||||||
|
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
[ -f "$src" ] || die "TODO: Source file $src does not exist."
|
if [ -f "$src" ]; then
|
||||||
[ -f "$dest" ] || die "TODO: Destination file $dest does not exist."
|
if [ -f "$dest" ]; then
|
||||||
|
if sed -ne "$item p" "$src" | grep "^."; then
|
||||||
|
MOVEME=$(sed "$item!d" "$src")
|
||||||
|
if [ $TODOTXT_FORCE = 0 ]; then
|
||||||
|
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||||
|
read ANSWER
|
||||||
|
else
|
||||||
|
ANSWER="y"
|
||||||
|
fi
|
||||||
|
if [ "$ANSWER" = "y" ]; then
|
||||||
|
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||||
|
# delete line (changes line numbers)
|
||||||
|
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$src"
|
||||||
|
else
|
||||||
|
# leave blank line behind (preserves line numbers)
|
||||||
|
sed -i.bak -e $item"s/^.*//" "$src"
|
||||||
|
fi
|
||||||
|
echo "$MOVEME" >> "$dest"
|
||||||
|
|
||||||
MOVEME=$(sed "$item!d" "$src")
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||||
[ -z "$MOVEME" ] && die "$item: No such item in $src."
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
if [ $TODOTXT_FORCE = 0 ]; then
|
_commit "TODO: '$MOVEME' moved from '$src' to '$dest'." \
|
||||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
$src $dest
|
||||||
read ANSWER
|
cleanup
|
||||||
else
|
else
|
||||||
ANSWER="y"
|
echo "TODO: No tasks moved."
|
||||||
fi
|
fi
|
||||||
if [ "$ANSWER" = "y" ]; then
|
else
|
||||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
echo "$item: No such item in $src."
|
||||||
# delete line (changes line numbers)
|
fi
|
||||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$src"
|
|
||||||
else
|
else
|
||||||
# leave blank line behind (preserves line numbers)
|
echo "TODO: Destination file $dest does not exist."
|
||||||
sed -i.bak -e $item"s/^.*//" "$src"
|
|
||||||
fi
|
|
||||||
echo "$MOVEME" >> "$dest"
|
|
||||||
|
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
|
||||||
echo "$item $MOVEME"
|
|
||||||
echo "TODO: $item moved from '$src' to '$dest'."
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "TODO: No tasks moved."
|
echo "TODO: Source file $src does not exist."
|
||||||
fi
|
fi
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
"prepend" | "prep" )
|
"prepend" | "prep" )
|
||||||
errmsg="usage: $TODO_SH prepend ITEM# \"TEXT TO PREPEND\""
|
errmsg="usage: $TODO_SH prepend ITEM# \"TEXT TO PREPEND\""
|
||||||
replaceOrPrepend 'prepend' "$@"
|
shift; item=$1; shift
|
||||||
;;
|
|
||||||
|
[ -z "$item" ] && die "$errmsg"
|
||||||
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
|
echo -n "Prepend: "
|
||||||
|
read input
|
||||||
|
else
|
||||||
|
input=$*
|
||||||
|
fi
|
||||||
|
cleaninput $input
|
||||||
|
|
||||||
|
# Test for then set priority
|
||||||
|
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||||
|
priority=$(sed "$item!d" "$TODO_FILE" | awk -F '\\(|\\)' '{print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If priority isn't set prepend
|
||||||
|
if [ -z $priority ]; then
|
||||||
|
if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
|
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
|
||||||
|
# If priority is set, remove priority, prepend and add back priority
|
||||||
|
else
|
||||||
|
if sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1 &|" "$TODO_FILE"; then
|
||||||
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
|
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
|
||||||
|
fi
|
||||||
|
cleanup;;
|
||||||
|
|
||||||
"pri" | "p" )
|
"pri" | "p" )
|
||||||
item=$2
|
item=$2
|
||||||
@@ -1014,20 +1070,56 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
if [ "$?" -eq 0 ]; then
|
if [ "$?" -eq 0 ]; then
|
||||||
#it's all good, continue
|
#it's all good, continue
|
||||||
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
||||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item $NEWTODO"
|
echo "`echo "$item: $NEWTODO"`"
|
||||||
echo "TODO: $item prioritized ($newpri)."
|
echo "TODO: $item prioritized ($newpri)."
|
||||||
fi
|
}
|
||||||
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
|
_commit "TODO: $item prioritized ($newpri)." $TODO_FILE
|
||||||
|
cleanup
|
||||||
else
|
else
|
||||||
die "$errmsg"
|
die "$errmsg"
|
||||||
fi
|
fi;;
|
||||||
;;
|
|
||||||
|
|
||||||
"replace" )
|
"replace" )
|
||||||
errmsg="usage: $TODO_SH replace ITEM# \"UPDATED ITEM\""
|
errmsg="usage: $TODO_SH replace ITEM# \"UPDATED ITEM\""
|
||||||
replaceOrPrepend 'replace' "$@"
|
shift; item=$1; shift
|
||||||
;;
|
|
||||||
|
[ -z "$item" ] && die "$errmsg"
|
||||||
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
# Test for then set priority
|
||||||
|
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||||
|
priority=$(sed "$item!d" "$TODO_FILE" | awk -F '\\(|\\)' '{print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
|
echo -n "Replacement: "
|
||||||
|
read input
|
||||||
|
else
|
||||||
|
input=$*
|
||||||
|
fi
|
||||||
|
cleaninput $input
|
||||||
|
|
||||||
|
# If priority isn't set replace, if it is remove priority, replace then add priority again
|
||||||
|
if [ -z $priority ]; then
|
||||||
|
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
||||||
|
else
|
||||||
|
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
||||||
|
fi
|
||||||
|
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" )
|
"report" )
|
||||||
#archive first
|
#archive first
|
||||||
@@ -1045,11 +1137,12 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
echo ${TDONE:-0})
|
echo ${TDONE:-0})
|
||||||
echo $TECHO >> "$REPORT_FILE"
|
echo $TECHO >> "$REPORT_FILE"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
||||||
|
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||||
|
_commit "TODO: Report file updated." $REPORT_FILE
|
||||||
cat "$REPORT_FILE"
|
cat "$REPORT_FILE"
|
||||||
;;
|
cleanup;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
usage;;
|
usage
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cleanup
|
|
||||||
|
|||||||
Reference in New Issue
Block a user