Compare commits
102 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94325f57cd | ||
|
|
938bbc1ec2 | ||
|
|
99f8911c8f | ||
|
|
f5d4249078 | ||
|
|
9b7f85bea1 | ||
|
|
a7afc7917d | ||
|
|
4d29e68e89 | ||
|
|
b383b1f0c5 | ||
|
|
8a95a66749 | ||
|
|
83053fd0c1 | ||
|
|
74fa07d26a | ||
|
|
3e597ce20e | ||
|
|
da466c9361 | ||
|
|
72caab8bbd | ||
|
|
7501b225c2 | ||
|
|
bcbf93ebe4 | ||
|
|
cea6d07735 | ||
|
|
2f4ba26994 | ||
|
|
5e44868261 | ||
|
|
2f6d9ae329 | ||
|
|
d46a12f14a | ||
|
|
95919765f7 | ||
|
|
2d0efff9a8 | ||
|
|
c58317258e | ||
|
|
38e2b8847f | ||
|
|
f72c1034ee | ||
|
|
37fcc53b26 | ||
|
|
e7b5841721 | ||
|
|
0b16bae2e8 | ||
|
|
8b7e2e6aad | ||
|
|
9f03cf6847 | ||
|
|
821b9d2795 | ||
|
|
c52d9c33af | ||
|
|
70b2c4ca40 | ||
|
|
69e756a2cd | ||
|
|
52b9db310f | ||
|
|
26bee144bd | ||
|
|
8ff3a7ce4a | ||
|
|
8bddb08196 | ||
|
|
391064e4f0 | ||
|
|
d52a1a7bd2 | ||
|
|
15084aa4d7 | ||
|
|
5876cc0437 | ||
|
|
370abbbf36 | ||
|
|
97eaa24b06 | ||
|
|
9e5e6aef39 | ||
|
|
edac86a94d | ||
|
|
948686a501 | ||
|
|
2a65615c7a | ||
|
|
d7e194b09d | ||
|
|
fd10678257 | ||
|
|
a4ab8a808a | ||
|
|
e395ac78d8 | ||
|
|
6fc2d81919 | ||
|
|
b6467eaa64 | ||
|
|
2d3820394a | ||
|
|
394c4c748a | ||
|
|
4c76f04a82 | ||
|
|
bf537934d7 | ||
|
|
2bb14eb9bc | ||
|
|
99511169c3 | ||
|
|
acc881f0dd | ||
|
|
d337933fd9 | ||
|
|
0a7e6337b2 | ||
|
|
0e326067e3 | ||
|
|
f6cf3fe76f | ||
|
|
20e04d5a4d | ||
|
|
9c56d2137a | ||
|
|
ceed8bf841 | ||
|
|
b8ced51a22 | ||
|
|
9a56bdd4ed | ||
|
|
9b580acf14 | ||
|
|
0d5904658e | ||
|
|
97866082e6 | ||
|
|
5f9fd4c759 | ||
|
|
5a49f4b5d5 | ||
|
|
f8e6a8d69d | ||
|
|
2983917f25 | ||
|
|
7a87077dfc | ||
|
|
51dd50b41d | ||
|
|
ddaf9ade22 | ||
|
|
ce8a0a7875 | ||
|
|
5e71728cda | ||
|
|
f44bcfb067 | ||
|
|
a19a3616c4 | ||
|
|
229737bd2f | ||
|
|
857121090a | ||
|
|
490f5d34e8 | ||
|
|
7baf051942 | ||
|
|
266d9e1258 | ||
|
|
e0b3ea1da9 | ||
|
|
35e80b3f33 | ||
|
|
294e2ac9a4 | ||
|
|
8d78cc6053 | ||
|
|
092e83404f | ||
|
|
91126e38aa | ||
|
|
5df58793a0 | ||
|
|
d2e892049d | ||
|
|
0e2798acce | ||
|
|
98569d5f8c | ||
|
|
75622c4a72 | ||
|
|
f9bb135068 |
@@ -10,7 +10,7 @@ to find it somewhere else.
|
||||
|
||||
# Remove the pre-created todo.cfg to test behavior in its absence
|
||||
rm -f todo.cfg
|
||||
echo "Fatal error: Cannot read configuration file $HOME/todo.cfg" > expect
|
||||
echo "Fatal Error: Cannot read configuration file $HOME/.todo/config" > expect
|
||||
test_expect_success 'no config file' '
|
||||
todo.sh > output 2>&1 || test_cmp expect output
|
||||
'
|
||||
@@ -32,6 +32,15 @@ EOF
|
||||
|
||||
rm -f used_config
|
||||
test_expect_success 'config file (default location 1)' '
|
||||
mkdir .todo
|
||||
cp test.cfg .todo/config
|
||||
todo.sh > output;
|
||||
test_cmp expect output && test -f used_config &&
|
||||
rm -rf .todo
|
||||
'
|
||||
|
||||
rm -f used_config
|
||||
test_expect_success 'config file (default location 2)' '
|
||||
cp test.cfg todo.cfg
|
||||
todo.sh > output;
|
||||
test_cmp expect output && test -f used_config &&
|
||||
@@ -39,7 +48,7 @@ test_expect_success 'config file (default location 1)' '
|
||||
'
|
||||
|
||||
rm -f used_config
|
||||
test_expect_success 'config file (default location 2)' '
|
||||
test_expect_success 'config file (default location 3)' '
|
||||
cp test.cfg .todo.cfg
|
||||
todo.sh > output;
|
||||
test_cmp expect output && test -f used_config &&
|
||||
|
||||
@@ -12,7 +12,7 @@ when there are no todos.
|
||||
#
|
||||
cat > expect <<EOF
|
||||
--
|
||||
TODO: 0 of 0 tasks shown from $HOME/todo.txt
|
||||
TODO: 0 of 0 tasks shown
|
||||
EOF
|
||||
|
||||
test_expect_success 'null ls' '
|
||||
@@ -44,7 +44,7 @@ test_expect_success 'null listpri a' '
|
||||
#
|
||||
cat > expect <<EOF
|
||||
--
|
||||
TODO: 0 of 0 tasks shown from $HOME/todo.tmp
|
||||
TODO: 0 of 0 tasks shown
|
||||
EOF
|
||||
|
||||
test_expect_success 'null lsa' '
|
||||
|
||||
40
tests/t0002-actions.sh
Executable file
40
tests/t0002-actions.sh
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/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,21 +12,23 @@ command work, including support for filtering.
|
||||
#
|
||||
test_todo_session 'basic add/list' <<EOF
|
||||
>>> todo.sh add notice the daisies
|
||||
TODO: 'notice the daisies' added on line 1.
|
||||
1 notice the daisies
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies
|
||||
--
|
||||
TODO: 1 of 1 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 1 tasks shown
|
||||
|
||||
>>> todo.sh add smell the roses
|
||||
TODO: 'smell the roses' added on line 2.
|
||||
2 smell the roses
|
||||
TODO: 2 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies
|
||||
2 smell the roses
|
||||
--
|
||||
TODO: 2 of 2 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
@@ -36,23 +38,39 @@ test_todo_session 'basic list filtering' <<EOF
|
||||
>>> todo.sh list daisies
|
||||
1 notice the daisies
|
||||
--
|
||||
TODO: 1 of 2 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 2 tasks shown
|
||||
|
||||
>>> todo.sh list smell
|
||||
2 smell the roses
|
||||
--
|
||||
TODO: 1 of 2 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'case-insensitive filtering' <<EOF
|
||||
>>> todo.sh add smell the uppercase Roses
|
||||
TODO: 'smell the uppercase Roses' added on line 3.
|
||||
3 smell the uppercase Roses
|
||||
TODO: 3 added.
|
||||
|
||||
>>> todo.sh list roses
|
||||
2 smell the roses
|
||||
3 smell the uppercase Roses
|
||||
--
|
||||
TODO: 2 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'add with &' <<EOF
|
||||
>>> todo.sh add "dig the garden & water the flowers"
|
||||
4 dig the garden & water the flowers
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh list
|
||||
4 dig the garden & water the flowers
|
||||
1 notice the daisies
|
||||
2 smell the roses
|
||||
3 smell the uppercase Roses
|
||||
--
|
||||
TODO: 4 of 4 tasks shown
|
||||
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
@@ -12,39 +12,42 @@ a date to each item.
|
||||
#
|
||||
test_todo_session 'cmd line first day' <<EOF
|
||||
>>> todo.sh -t add notice the daisies
|
||||
TODO: '2009-02-13 notice the daisies' added on line 1.
|
||||
1 2009-02-13 notice the daisies
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
--
|
||||
TODO: 1 of 1 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 1 tasks shown
|
||||
EOF
|
||||
|
||||
test_tick
|
||||
|
||||
test_todo_session 'cmd line second day' <<EOF
|
||||
>>> todo.sh -t add smell the roses
|
||||
TODO: '2009-02-14 smell the roses' added on line 2.
|
||||
2 2009-02-14 smell the roses
|
||||
TODO: 2 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
2 2009-02-14 smell the roses
|
||||
--
|
||||
TODO: 2 of 2 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
test_tick
|
||||
|
||||
test_todo_session 'cmd line third day' <<EOF
|
||||
>>> todo.sh -t add mow the lawn
|
||||
TODO: '2009-02-15 mow the lawn' added on line 3.
|
||||
3 2009-02-15 mow the lawn
|
||||
TODO: 3 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
2 2009-02-14 smell the roses
|
||||
3 2009-02-15 mow the lawn
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
# Switch to config file
|
||||
@@ -55,7 +58,8 @@ test_tick 3600
|
||||
|
||||
test_todo_session 'config file third day' <<EOF
|
||||
>>> todo.sh add take out the trash
|
||||
TODO: '2009-02-15 take out the trash' added on line 4.
|
||||
4 2009-02-15 take out the trash
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -63,7 +67,7 @@ TODO: '2009-02-15 take out the trash' added on line 4.
|
||||
3 2009-02-15 mow the lawn
|
||||
4 2009-02-15 take out the trash
|
||||
--
|
||||
TODO: 4 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 4 of 4 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
83
tests/t1020-addtolistfile.sh
Executable file
83
tests/t1020-addtolistfile.sh
Executable file
@@ -0,0 +1,83 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic addto and list functionality
|
||||
|
||||
This test just makes sure the basic addto and listfile
|
||||
commands work, including support for filtering.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#
|
||||
# Addto and listfile
|
||||
#
|
||||
test_todo_session 'nonexistant file' <<EOF
|
||||
>>> todo.sh addto garden.txt notice the daisies
|
||||
TODO: Destination file $HOME/garden.txt does not exist.
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
touch "$HOME/garden.txt"
|
||||
|
||||
test_todo_session 'basic addto/listfile' <<EOF
|
||||
>>> todo.sh addto garden.txt notice the daisies
|
||||
1 notice the daisies
|
||||
GARDEN: 1 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 notice the daisies
|
||||
--
|
||||
GARDEN: 1 of 1 tasks shown
|
||||
|
||||
>>> todo.sh addto garden.txt smell the roses
|
||||
2 smell the roses
|
||||
GARDEN: 2 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 notice the daisies
|
||||
2 smell the roses
|
||||
--
|
||||
GARDEN: 2 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# Filter
|
||||
#
|
||||
test_todo_session 'basic listfile filtering' <<EOF
|
||||
>>> todo.sh listfile garden.txt daisies
|
||||
1 notice the daisies
|
||||
--
|
||||
GARDEN: 1 of 2 tasks shown
|
||||
|
||||
>>> todo.sh listfile garden.txt smell
|
||||
2 smell the roses
|
||||
--
|
||||
GARDEN: 1 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'case-insensitive filtering' <<EOF
|
||||
>>> todo.sh addto garden.txt smell the uppercase Roses
|
||||
3 smell the uppercase Roses
|
||||
GARDEN: 3 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt roses
|
||||
2 smell the roses
|
||||
3 smell the uppercase Roses
|
||||
--
|
||||
GARDEN: 2 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'addto with &' <<EOF
|
||||
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
|
||||
4 dig the garden & water the flowers
|
||||
GARDEN: 4 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
4 dig the garden & water the flowers
|
||||
1 notice the daisies
|
||||
2 smell the roses
|
||||
3 smell the uppercase Roses
|
||||
--
|
||||
GARDEN: 4 of 4 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
75
tests/t1030-addto-date.sh
Executable file
75
tests/t1030-addto-date.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='test the date on addto feature
|
||||
|
||||
Tests paths by which we might automatically add
|
||||
a date to each item.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
touch "$HOME/garden.txt"
|
||||
|
||||
#
|
||||
# Add and list
|
||||
#
|
||||
test_todo_session 'cmd line first day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt notice the daisies
|
||||
1 2009-02-13 notice the daisies
|
||||
GARDEN: 1 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
--
|
||||
GARDEN: 1 of 1 tasks shown
|
||||
EOF
|
||||
|
||||
test_tick
|
||||
|
||||
test_todo_session 'cmd line second day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt smell the roses
|
||||
2 2009-02-14 smell the roses
|
||||
GARDEN: 2 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
2 2009-02-14 smell the roses
|
||||
--
|
||||
GARDEN: 2 of 2 tasks shown
|
||||
EOF
|
||||
|
||||
test_tick
|
||||
|
||||
test_todo_session 'cmd line third day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt mow the lawn
|
||||
3 2009-02-15 mow the lawn
|
||||
GARDEN: 3 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
2 2009-02-14 smell the roses
|
||||
3 2009-02-15 mow the lawn
|
||||
--
|
||||
GARDEN: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
# Switch to config file
|
||||
echo "export TODOTXT_DATE_ON_ADD=1" >> todo.cfg
|
||||
|
||||
# Bump the clock, for good measure.
|
||||
test_tick 3600
|
||||
|
||||
test_todo_session 'config file third day' <<EOF
|
||||
>>> todo.sh addto garden.txt take out the trash
|
||||
4 2009-02-15 take out the trash
|
||||
GARDEN: 4 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
2 2009-02-14 smell the roses
|
||||
3 2009-02-15 mow the lawn
|
||||
4 2009-02-15 take out the trash
|
||||
--
|
||||
GARDEN: 4 of 4 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
@@ -19,24 +19,24 @@ EOF
|
||||
|
||||
test_todo_session 'basic replace' <<EOF
|
||||
>>> todo.sh replace 1 "smell the cows"
|
||||
1: notice the daisies
|
||||
replaced with
|
||||
1: smell the cows
|
||||
1 notice the daisies
|
||||
TODO: Replaced task with:
|
||||
1 smell the cows
|
||||
|
||||
>>> todo.sh list
|
||||
1 smell the cows
|
||||
--
|
||||
TODO: 1 of 1 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 1 tasks shown
|
||||
|
||||
>>> todo.sh replace 1 smell the roses
|
||||
1: smell the cows
|
||||
replaced with
|
||||
1: smell the roses
|
||||
1 smell the cows
|
||||
TODO: Replaced task with:
|
||||
1 smell the roses
|
||||
|
||||
>>> todo.sh list
|
||||
1 smell the roses
|
||||
--
|
||||
TODO: 1 of 1 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 1 tasks shown
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
@@ -47,25 +47,88 @@ chase the chickens
|
||||
EOF
|
||||
test_todo_session 'replace in multi-item file' <<EOF
|
||||
>>> todo.sh replace 1 smell the cheese
|
||||
1: smell the cows
|
||||
replaced with
|
||||
1: smell the cheese
|
||||
1 smell the cows
|
||||
TODO: Replaced task with:
|
||||
1 smell the cheese
|
||||
|
||||
>>> todo.sh replace 3 jump on hay
|
||||
3: thrash some hay
|
||||
replaced with
|
||||
3: jump on hay
|
||||
3 thrash some hay
|
||||
TODO: Replaced task with:
|
||||
3 jump on hay
|
||||
|
||||
>>> todo.sh replace 4 collect the eggs
|
||||
4: chase the chickens
|
||||
replaced with
|
||||
4: collect the eggs
|
||||
4 chase the chickens
|
||||
TODO: Replaced task with:
|
||||
4 collect the eggs
|
||||
EOF
|
||||
|
||||
test_todo_session 'replace with priority' <<EOF
|
||||
>>> todo.sh pri 4 a
|
||||
4 (A) collect the eggs
|
||||
TODO: 4 prioritized (A).
|
||||
|
||||
>>> todo.sh replace 4 "collect the bread"
|
||||
4 (A) collect the eggs
|
||||
TODO: Replaced task with:
|
||||
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
|
||||
|
||||
test_todo_session 'replace with &' << EOF
|
||||
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"
|
||||
3 jump on hay
|
||||
TODO: Replaced task with:
|
||||
3 thrash the hay & thresh the wheat
|
||||
EOF
|
||||
|
||||
test_todo_session 'replace error' << EOF
|
||||
>>> todo.sh replace 10 "hej!"
|
||||
=== 1
|
||||
10: No such todo.
|
||||
TODO: No task 10.
|
||||
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
|
||||
|
||||
test_done
|
||||
|
||||
@@ -22,10 +22,10 @@ test_todo_session 'basic priority' <<EOF
|
||||
1 smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> 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.sh list
|
||||
@@ -33,17 +33,17 @@ TODO: 1 prioritized (B).
|
||||
2 notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
2 notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh pri 2 C
|
||||
2: (C) notice the sunflowers
|
||||
2 (C) notice the sunflowers
|
||||
TODO: 2 prioritized (C).
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -51,10 +51,10 @@ TODO: 2 prioritized (C).
|
||||
2 (C) notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh pri 2 A
|
||||
2: (A) notice the sunflowers
|
||||
2 (A) notice the sunflowers
|
||||
TODO: 2 prioritized (A).
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -62,20 +62,21 @@ TODO: 2 prioritized (A).
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh pri 2 a
|
||||
2: (A) notice the sunflowers
|
||||
2 (A) notice the sunflowers
|
||||
TODO: 2 prioritized (A).
|
||||
|
||||
>>> todo.sh -p listpri
|
||||
2 (A) notice the sunflowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
--
|
||||
TODO: 2 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 3 tasks shown
|
||||
|
||||
>>> todo.sh add "smell the coffee +wakeup"
|
||||
TODO: 'smell the coffee +wakeup' added on line 4.
|
||||
4 smell the coffee +wakeup
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
@@ -83,7 +84,7 @@ TODO: 'smell the coffee +wakeup' added on line 4.
|
||||
4 smell the coffee +wakeup
|
||||
3 stop
|
||||
--
|
||||
TODO: 4 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 4 of 4 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
@@ -28,14 +28,14 @@ test_todo_session 'checking TODOTXT_SORT_COMMAND' <<EOF
|
||||
3 bbb yyy this line should be second.
|
||||
1 ccc xxx this line should be third.
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh -d "$TEST_TODO1_" ls
|
||||
1 ccc xxx this line should be third.
|
||||
3 bbb yyy this line should be second.
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
@@ -50,7 +50,75 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <<EOF
|
||||
3 bbb yyy this line s...
|
||||
1 ccc xxx this line s...
|
||||
--
|
||||
TODO: 3 of 3 tasks shown from $HOME/todo.txt
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the filtering of TERM
|
||||
#
|
||||
test_todo_session 'checking filtering of TERM' <<EOF
|
||||
>>> todo.sh ls second
|
||||
3 bbb yyy this line should be second.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "should be f"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls " zzz"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the filtering of TERM with regexp
|
||||
#
|
||||
test_todo_session 'checking filtering of TERM with regexp' <<EOF
|
||||
>>> todo.sh ls "ir[ds]"
|
||||
2 aaa zzz this line should be first.
|
||||
1 ccc xxx this line should be third.
|
||||
--
|
||||
TODO: 2 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "f.*t"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "ir[ds]" xxx
|
||||
1 ccc xxx this line should be third.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the x command line option
|
||||
#
|
||||
TEST_TODO3_=todo3.cfg
|
||||
sed -e "s%^.*export TODOTXT_FINAL_FILTER=.*$%export TODOTXT_FINAL_FILTER=\"grep -v xxx\"%" "${TEST_TODO_}" > "${TEST_TODO3_}"
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
foo
|
||||
bar xxx
|
||||
baz
|
||||
EOF
|
||||
|
||||
test_todo_session 'final filter suppression' <<EOF
|
||||
>>> todo.sh -d "$TEST_TODO3_" ls
|
||||
3 baz
|
||||
1 foo
|
||||
--
|
||||
TODO: 2 of 3 tasks shown
|
||||
|
||||
>>> todo.sh -d "$TEST_TODO3_" -x ls
|
||||
2 bar xxx
|
||||
3 baz
|
||||
1 foo
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
@@ -101,7 +169,7 @@ test_todo_session 'plain mode option' <<EOF
|
||||
19 @con02 +prj03 -- Some project 03 task, no priorty
|
||||
20 @con02 +prj04 -- Some project 04 task, no priority
|
||||
--
|
||||
TODO: 20 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 20 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -p ls
|
||||
01 (A) @con01 +prj01 -- Some project 01 task, pri A
|
||||
@@ -125,7 +193,7 @@ TODO: 20 of 20 tasks shown from $HOME/todo.txt
|
||||
19 @con02 +prj03 -- Some project 03 task, no priorty
|
||||
20 @con02 +prj04 -- Some project 04 task, no priority
|
||||
--
|
||||
TODO: 20 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 20 of 20 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
@@ -176,7 +244,7 @@ test_todo_session 'context, project, and priority suppression' <<EOF
|
||||
19 @con02 +prj03 -- Some project 03 task, no priorty
|
||||
20 @con02 +prj04 -- Some project 04 task, no priority
|
||||
--
|
||||
TODO: 20 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 20 of 20 tasks shown
|
||||
|
||||
>>> todo.sh ls @con01
|
||||
[1;33m01 (A) @con01 +prj01 -- Some project 01 task, pri A[0m
|
||||
@@ -190,7 +258,7 @@ TODO: 20 of 20 tasks shown from $HOME/todo.txt
|
||||
17 @con01 +prj01 -- Some project 01 task, no priority
|
||||
18 @con01 +prj02 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -P ls @con01
|
||||
[1;33m01 @con01 +prj01 -- Some project 01 task, pri A[0m
|
||||
@@ -204,7 +272,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 @con01 +prj01 -- Some project 01 task, no priority
|
||||
18 @con01 +prj02 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -+ ls @con01
|
||||
[1;33m01 (A) @con01 -- Some project 01 task, pri A[0m
|
||||
@@ -218,7 +286,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 @con01 -- Some project 01 task, no priority
|
||||
18 @con01 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -@ ls @con01
|
||||
[1;33m01 (A) +prj01 -- Some project 01 task, pri A[0m
|
||||
@@ -232,7 +300,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 +prj01 -- Some project 01 task, no priority
|
||||
18 +prj02 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -P -@ ls @con01
|
||||
[1;33m01 +prj01 -- Some project 01 task, pri A[0m
|
||||
@@ -246,7 +314,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 +prj01 -- Some project 01 task, no priority
|
||||
18 +prj02 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -P -@ -+ -P -@ -+ ls @con01
|
||||
[1;33m01 (A) @con01 +prj01 -- Some project 01 task, pri A[0m
|
||||
@@ -260,7 +328,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 @con01 +prj01 -- Some project 01 task, no priority
|
||||
18 @con01 +prj02 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
|
||||
>>> todo.sh -P -@ -+ -P -@ -+ -P -@ -+ ls @con01
|
||||
[1;33m01 -- Some project 01 task, pri A[0m
|
||||
@@ -274,7 +342,7 @@ TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
17 -- Some project 01 task, no priority
|
||||
18 -- Some project 02 task, no priority
|
||||
--
|
||||
TODO: 10 of 20 tasks shown from $HOME/todo.txt
|
||||
TODO: 10 of 20 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
@@ -509,7 +577,88 @@ test_todo_session 'check line number padding, out to 3 digits' <<EOF
|
||||
111 hex6E this is another line
|
||||
112 hex6F this is another line
|
||||
--
|
||||
TODO: 112 of 112 tasks shown from $HOME/todo.txt
|
||||
TODO: 112 of 112 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check that blank lines are ignored.
|
||||
#
|
||||
|
||||
# Less than 10
|
||||
cat > todo.txt <<EOF
|
||||
hex00 this is one line
|
||||
|
||||
hex02 this is another line
|
||||
hex03 this is another line
|
||||
hex04 this is another line
|
||||
hex05 this is another line
|
||||
hex06 this is another line
|
||||
hex07 this is another line
|
||||
EOF
|
||||
test_todo_session 'check that blank lines are ignored for less than 10 items' <<EOF
|
||||
>>> todo.sh ls
|
||||
1 hex00 this is one line
|
||||
3 hex02 this is another line
|
||||
4 hex03 this is another line
|
||||
5 hex04 this is another line
|
||||
6 hex05 this is another line
|
||||
7 hex06 this is another line
|
||||
8 hex07 this is another line
|
||||
--
|
||||
TODO: 7 of 7 tasks shown
|
||||
EOF
|
||||
|
||||
# More than 10
|
||||
cat > todo.txt <<EOF
|
||||
hex00 this is one line
|
||||
|
||||
hex02 this is another line
|
||||
hex03 this is another line
|
||||
hex04 this is another line
|
||||
hex05 this is another line
|
||||
hex06 this is another line
|
||||
hex07 this is another line
|
||||
hex08 this is another line
|
||||
hex09 this is another line
|
||||
EOF
|
||||
test_todo_session 'check that blank lines are ignored for blank lines whose ID begins with `0` (one blank)' <<EOF
|
||||
>>> todo.sh ls
|
||||
01 hex00 this is one line
|
||||
03 hex02 this is another line
|
||||
04 hex03 this is another line
|
||||
05 hex04 this is another line
|
||||
06 hex05 this is another line
|
||||
07 hex06 this is another line
|
||||
08 hex07 this is another line
|
||||
09 hex08 this is another line
|
||||
10 hex09 this is another line
|
||||
--
|
||||
TODO: 9 of 9 tasks shown
|
||||
EOF
|
||||
cat > todo.txt <<EOF
|
||||
hex00 this is one line
|
||||
|
||||
hex02 this is another line
|
||||
hex03 this is another line
|
||||
hex04 this is another line
|
||||
hex05 this is another line
|
||||
|
||||
hex07 this is another line
|
||||
hex08 this is another line
|
||||
hex09 this is another line
|
||||
EOF
|
||||
test_todo_session 'check that blank lines are ignored for blank lines whose ID begins with `0` (many blanks)' <<EOF
|
||||
>>> todo.sh ls
|
||||
01 hex00 this is one line
|
||||
03 hex02 this is another line
|
||||
04 hex03 this is another line
|
||||
05 hex04 this is another line
|
||||
06 hex05 this is another line
|
||||
08 hex07 this is another line
|
||||
09 hex08 this is another line
|
||||
10 hex09 this is another line
|
||||
--
|
||||
TODO: 8 of 8 tasks shown
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
151
tests/t1330-ls-highlighting.sh
Executable file
151
tests/t1330-ls-highlighting.sh
Executable file
@@ -0,0 +1,151 @@
|
||||
#!/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
|
||||
94
tests/t1400-prepend.sh
Executable file
94
tests/t1400-prepend.sh
Executable file
@@ -0,0 +1,94 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic prepend functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
test_todo_session 'prepend usage' <<EOF
|
||||
>>> todo.sh prepend B B
|
||||
usage: todo.sh prepend ITEM# "TEXT TO PREPEND"
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
(B) smell the uppercase Roses +flowers @outside
|
||||
notice the sunflowers
|
||||
stop
|
||||
EOF
|
||||
test_todo_session 'basic prepend' <<EOF
|
||||
>>> todo.sh list
|
||||
[0;32m1 (B) smell the uppercase Roses +flowers @outside[0m
|
||||
2 notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
2 notice the sunflowers
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh prepend 2 test
|
||||
2 test notice the sunflowers
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
2 test notice the sunflowers
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh prepend 1 test
|
||||
1 (B) test smell the uppercase Roses +flowers @outside
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) test smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
2 test notice the sunflowers
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
EOF
|
||||
|
||||
test_todo_session 'prepend with &' <<EOF
|
||||
>>> todo.sh prepend 3 "no running & jumping now"
|
||||
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
|
||||
|
||||
test_done
|
||||
86
tests/t1500-do.sh
Executable file
86
tests/t1500-do.sh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='do functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#DATE=`date '+%Y-%m-%d'`
|
||||
|
||||
test_todo_session 'do usage' <<EOF
|
||||
>>> todo.sh do B B
|
||||
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
test_todo_session 'do missing ITEM#' <<EOF
|
||||
>>> todo.sh do
|
||||
usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...]
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
smell the uppercase Roses +flowers @outside
|
||||
notice the sunflowers
|
||||
stop
|
||||
remove1
|
||||
remove2
|
||||
remove3
|
||||
remove4
|
||||
EOF
|
||||
|
||||
test_todo_session 'basic do' <<EOF
|
||||
>>> todo.sh list
|
||||
2 notice the sunflowers
|
||||
4 remove1
|
||||
5 remove2
|
||||
6 remove3
|
||||
7 remove4
|
||||
1 smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 7 of 7 tasks shown
|
||||
|
||||
>>> todo.sh do 7,6
|
||||
7 x 2009-02-13 remove4
|
||||
TODO: 7 marked as done.
|
||||
6 x 2009-02-13 remove3
|
||||
TODO: 6 marked as done.
|
||||
x 2009-02-13 remove3
|
||||
x 2009-02-13 remove4
|
||||
TODO: $HOME/todo.txt archived.
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 notice the sunflowers
|
||||
4 remove1
|
||||
5 remove2
|
||||
1 smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh do 5 4
|
||||
5 x 2009-02-13 remove2
|
||||
TODO: 5 marked as done.
|
||||
4 x 2009-02-13 remove1
|
||||
TODO: 4 marked as done.
|
||||
x 2009-02-13 remove1
|
||||
x 2009-02-13 remove2
|
||||
TODO: $HOME/todo.txt archived.
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 notice the sunflowers
|
||||
1 smell the uppercase Roses +flowers @outside
|
||||
3 stop
|
||||
--
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'fail multiple do attempts' <<EOF
|
||||
>>> todo.sh -a do 3
|
||||
3 x 2009-02-13 stop
|
||||
TODO: 3 marked as done.
|
||||
|
||||
>>> todo.sh -a do 3
|
||||
3 is already marked done
|
||||
EOF
|
||||
test_done
|
||||
76
tests/t1600-append.sh
Executable file
76
tests/t1600-append.sh
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='basic append functionality
|
||||
|
||||
Ensure we can append items successfully.
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#
|
||||
# Set up the basic todo.txt
|
||||
#
|
||||
todo.sh add notice the daisies > /dev/null
|
||||
|
||||
test_todo_session 'append usage' <<EOF
|
||||
>>> todo.sh append adf asdfa
|
||||
=== 1
|
||||
usage: todo.sh append ITEM# "TEXT TO APPEND"
|
||||
EOF
|
||||
|
||||
test_todo_session 'basic append' <<EOF
|
||||
>>> todo.sh append 1 "smell the roses"
|
||||
1 notice the daisies smell the roses
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies smell the roses
|
||||
--
|
||||
TODO: 1 of 1 tasks shown
|
||||
EOF
|
||||
|
||||
test_todo_session 'basic append with &' <<EOF
|
||||
>>> todo.sh append 1 "see the wasps & bees"
|
||||
1 notice the daisies smell the roses see the wasps & bees
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies smell the roses see the wasps & bees
|
||||
--
|
||||
TODO: 1 of 1 tasks shown
|
||||
EOF
|
||||
|
||||
|
||||
test_todo_session 'append error' << EOF
|
||||
>>> todo.sh append 10 "hej!"
|
||||
=== 1
|
||||
TODO: No task 10.
|
||||
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
|
||||
|
||||
test_done
|
||||
71
tests/t1700-depri.sh
Executable file
71
tests/t1700-depri.sh
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/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
|
||||
153
tests/t1800-del.sh
Executable file
153
tests/t1800-del.sh
Executable file
@@ -0,0 +1,153 @@
|
||||
#!/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
|
||||
136
tests/t2000-multiline.sh
Executable file
136
tests/t2000-multiline.sh
Executable file
@@ -0,0 +1,136 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='Multi-line functionality'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
## Replace test
|
||||
# Create the expected file
|
||||
echo "1 smell the cheese
|
||||
TODO: Replaced task with:
|
||||
1 eat apples eat oranges drink milk">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item replace' '
|
||||
(
|
||||
# Prepare single line todo file
|
||||
cat /dev/null > $HOME/todo.txt
|
||||
"$HOME/bin/todo.sh" add smell the cheese
|
||||
|
||||
# Run replace
|
||||
"$HOME/bin/todo.sh" replace 1 "eat apples
|
||||
eat oranges
|
||||
drink milk" > $HOME/output.multi
|
||||
|
||||
# Test output against expected
|
||||
diff "$HOME/output.multi" "$HOME/expect.multi"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
)
|
||||
'
|
||||
|
||||
## Add test
|
||||
# Create the expected file
|
||||
echo "2 eat apples eat oranges drink milk
|
||||
TODO: 2 added.">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item add' '
|
||||
(
|
||||
# Prepare single line todo file
|
||||
cat /dev/null > $HOME/todo.txt
|
||||
"$HOME/bin/todo.sh" add smell the cheese
|
||||
|
||||
# Run add
|
||||
"$HOME/bin/todo.sh" add "eat apples
|
||||
eat oranges
|
||||
drink milk" > $HOME/output.multi
|
||||
|
||||
# Test output against expected
|
||||
diff "$HOME/output.multi" "$HOME/expect.multi"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
)
|
||||
'
|
||||
|
||||
## Append test
|
||||
# Create the expected file
|
||||
echo "1 smell the cheese eat apples eat oranges drink milk">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item append' '
|
||||
(
|
||||
# Prepare single line todo file
|
||||
cat /dev/null > $HOME/todo.txt
|
||||
"$HOME/bin/todo.sh" add smell the cheese
|
||||
|
||||
# Run append
|
||||
"$HOME/bin/todo.sh" append 1 "eat apples
|
||||
eat oranges
|
||||
drink milk" > $HOME/output.multi
|
||||
|
||||
# Test output against expected
|
||||
diff "$HOME/output.multi" "$HOME/expect.multi"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
)
|
||||
'
|
||||
|
||||
## Prepend test
|
||||
# Create the expected file
|
||||
echo "1 eat apples eat oranges drink milk smell the cheese">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item prepend' '
|
||||
(
|
||||
# Prepare single line todo file
|
||||
cat /dev/null > $HOME/todo.txt
|
||||
"$HOME/bin/todo.sh" add smell the cheese
|
||||
|
||||
# Run prepend
|
||||
"$HOME/bin/todo.sh" prepend 1 "eat apples
|
||||
eat oranges
|
||||
drink milk" > $HOME/output.multi
|
||||
|
||||
# Test output against expected
|
||||
diff "$HOME/output.multi" "$HOME/expect.multi"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
)
|
||||
'
|
||||
|
||||
## Multiple line addition
|
||||
# Create the expected file
|
||||
echo "2 eat apples
|
||||
TODO: 2 added." > $HOME/expect.multi
|
||||
echo "3 eat oranges
|
||||
TODO: 3 added." >>$HOME/expect.multi
|
||||
echo "4 drink milk
|
||||
TODO: 4 added." >> $HOME/expect.multi
|
||||
|
||||
test_expect_success 'actual multiline add' '
|
||||
(
|
||||
# Run addm
|
||||
"$HOME/bin/todo.sh" addm "eat apples
|
||||
eat oranges
|
||||
drink milk" > $HOME/output.multi
|
||||
|
||||
# Test output against expected
|
||||
diff "$HOME/output.multi" "$HOME/expect.multi"
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
)
|
||||
'
|
||||
|
||||
test_done
|
||||
52
tests/t8000-actions.sh
Executable file
52
tests/t8000-actions.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/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
|
||||
@@ -17,26 +17,26 @@ test_todo_session 'basic tests' <<EOF
|
||||
4 smell the coffee +wakeup
|
||||
3 stop
|
||||
--
|
||||
TODO: 4 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 4 of 4 tasks shown
|
||||
|
||||
>>> todo.sh -p list +flowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
--
|
||||
TODO: 1 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 4 tasks shown
|
||||
|
||||
>>> todo.sh -p list flowers
|
||||
2 (A) notice the sunflowers
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
--
|
||||
TODO: 2 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 4 tasks shown
|
||||
|
||||
>>> todo.sh -p list flowers out
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
--
|
||||
TODO: 1 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 1 of 4 tasks shown
|
||||
|
||||
>>> 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.sh -p list
|
||||
@@ -45,19 +45,21 @@ TODO: 2 marked as done.
|
||||
3 stop
|
||||
2 x 2009-02-13 notice the sunflowers
|
||||
--
|
||||
TODO: 4 of 4 tasks shown from $HOME/todo.txt
|
||||
TODO: 4 of 4 tasks shown
|
||||
|
||||
>>> todo.sh add "make the coffee +wakeup"
|
||||
TODO: 'make the coffee +wakeup' added on line 5.
|
||||
5 make the coffee +wakeup
|
||||
TODO: 5 added.
|
||||
|
||||
>>> todo.sh -p list coffee
|
||||
5 make the coffee +wakeup
|
||||
4 smell the coffee +wakeup
|
||||
--
|
||||
TODO: 2 of 5 tasks shown from $HOME/todo.txt
|
||||
TODO: 2 of 5 tasks shown
|
||||
|
||||
>>> todo.sh add "visit http://example.com"
|
||||
TODO: 'visit http://example.com' added on line 6.
|
||||
6 visit http://example.com
|
||||
TODO: 6 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -67,7 +69,7 @@ TODO: 'visit http://example.com' added on line 6.
|
||||
6 visit http://example.com
|
||||
2 x 2009-02-13 notice the sunflowers
|
||||
--
|
||||
TODO: 6 of 6 tasks shown from $HOME/todo.txt
|
||||
TODO: 6 of 6 tasks shown
|
||||
|
||||
>>> todo.sh archive
|
||||
x 2009-02-13 notice the sunflowers
|
||||
@@ -80,7 +82,7 @@ TODO: $HOME/todo.txt archived.
|
||||
2 stop
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh report
|
||||
TODO: Report file updated.
|
||||
@@ -96,7 +98,7 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
||||
=== 1
|
||||
|
||||
>>> todo.sh append 2 and think
|
||||
2: stop and think
|
||||
2 stop and think
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -105,10 +107,10 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
||||
2 stop and think
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh append 10 "hej!"
|
||||
10: No such todo.
|
||||
TODO: No task 10.
|
||||
=== 1
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -118,10 +120,10 @@ TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
2 stop and think
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh do 10
|
||||
10: No such todo.
|
||||
TODO: No task 10.
|
||||
=== 1
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -131,10 +133,11 @@ TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
2 stop and think
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 5 of 5 tasks shown from $HOME/todo.txt
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh add "the coffee +wakeup"
|
||||
TODO: 'the coffee +wakeup' added on line 6.
|
||||
6 the coffee +wakeup
|
||||
TODO: 6 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -144,10 +147,10 @@ TODO: 'the coffee +wakeup' added on line 6.
|
||||
6 the coffee +wakeup
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 6 of 6 tasks shown from $HOME/todo.txt
|
||||
TODO: 6 of 6 tasks shown
|
||||
|
||||
>>> todo.sh prepend 6 "make"
|
||||
6: make the coffee +wakeup
|
||||
6 make the coffee +wakeup
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -157,7 +160,7 @@ TODO: 6 of 6 tasks shown from $HOME/todo.txt
|
||||
2 stop and think
|
||||
5 visit http://example.com
|
||||
--
|
||||
TODO: 6 of 6 tasks shown from $HOME/todo.txt
|
||||
TODO: 6 of 6 tasks shown
|
||||
|
||||
>>> todo.sh remdup
|
||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
||||
|
||||
@@ -542,7 +542,7 @@ test_todo_session () {
|
||||
if [ $status = 0 ]; then
|
||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||
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
|
||||
|
||||
subnum=$(($subnum + 1))
|
||||
@@ -560,7 +560,7 @@ test_todo_session () {
|
||||
if [ $status = 0 ]; then
|
||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||
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
|
||||
}
|
||||
|
||||
26
todo.cfg
26
todo.cfg
@@ -17,8 +17,13 @@ export TMP_FILE="$TODO_DIR/todo.tmp"
|
||||
|
||||
# === COLOR MAP ===
|
||||
|
||||
## If you have re-mapped your color codes, you may need to
|
||||
## Text coloring and formatting is done by inserting ANSI escape codes.
|
||||
## 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.
|
||||
## 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 RED='\\033[0;31m'
|
||||
@@ -38,16 +43,25 @@ export TMP_FILE="$TODO_DIR/todo.tmp"
|
||||
# export WHITE='\\033[1;37m'
|
||||
# export DEFAULT='\\033[0m'
|
||||
|
||||
# === PRIORITY COLORS ===
|
||||
# === COLORS ===
|
||||
|
||||
## Priorities can be any upper-case letter.
|
||||
## Colors are supported for the first three.
|
||||
## 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_B=$GREEN # color for B priority
|
||||
# export PRI_C=$LIGHT_BLUE # color for C priority
|
||||
# export PRI_X=$WHITE # color for rest of them
|
||||
# export PRI_D=... # define your own
|
||||
# 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 ===
|
||||
|
||||
|
||||
575
todo.sh
575
todo.sh
@@ -1,10 +1,14 @@
|
||||
#! /bin/bash
|
||||
|
||||
# NOTE: Todo.sh requires the todo.cfg configuration file to run.
|
||||
# Place the todo.cfg file in your home directory or use the -d option for a custom location.
|
||||
# === HEAVY LIFTING ===
|
||||
shopt -s extglob
|
||||
|
||||
# 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.
|
||||
|
||||
[ -f VERSION-FILE ] && . VERSION-FILE || VERSION="@DEV_VERSION@"
|
||||
version() { sed -e 's/^ //' <<EndVersion
|
||||
version() {
|
||||
cat <<-EndVersion
|
||||
TODO.TXT Command Line Interface v$VERSION
|
||||
|
||||
First release: 5/11/2006
|
||||
@@ -13,39 +17,42 @@ version() { sed -e 's/^ //' <<EndVersion
|
||||
License: GPL, http://www.gnu.org/copyleft/gpl.html
|
||||
More information and mailing list at http://todotxt.com
|
||||
Code repository: http://github.com/ginatrapani/todo.txt-cli/tree/master
|
||||
EndVersion
|
||||
EndVersion
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set script name early.
|
||||
# Set script name and full path early.
|
||||
TODO_SH=$(basename "$0")
|
||||
export TODO_SH
|
||||
TODO_FULL_SH="$0"
|
||||
export TODO_SH TODO_FULL_SH
|
||||
|
||||
oneline_usage="$TODO_SH [-fhpantvV] [-d todo_config] action [task_number] [task_description]"
|
||||
|
||||
usage()
|
||||
{
|
||||
sed -e 's/^ //' <<EndUsage
|
||||
cat <<-EndUsage
|
||||
Usage: $oneline_usage
|
||||
Try '$TODO_SH -h' for more information.
|
||||
EndUsage
|
||||
EndUsage
|
||||
exit 1
|
||||
}
|
||||
|
||||
shorthelp()
|
||||
{
|
||||
sed -e 's/^ //' <<EndHelp
|
||||
cat <<-EndHelp
|
||||
Usage: $oneline_usage
|
||||
|
||||
Actions:
|
||||
add|a "THING I NEED TO DO +project @context"
|
||||
addto DEST "TEXT TO ADD"
|
||||
append|app NUMBER "TEXT TO APPEND"
|
||||
addm "THINGS I NEED TO DO
|
||||
MORE THINGS I NEED TO DO"
|
||||
append|app ITEM# "TEXT TO APPEND"
|
||||
archive
|
||||
command [ACTIONS]
|
||||
del|rm NUMBER [TERM]
|
||||
dp|depri NUMBER
|
||||
do NUMBER
|
||||
del|rm ITEM# [TERM]
|
||||
dp|depri ITEM#[, ITEM#, ITEM#, ...]
|
||||
do ITEM#[, ITEM#, ITEM#, ...]
|
||||
help
|
||||
list|ls [TERM...]
|
||||
listall|lsa [TERM...]
|
||||
@@ -53,20 +60,20 @@ shorthelp()
|
||||
listfile|lf SRC [TERM...]
|
||||
listpri|lsp [PRIORITY]
|
||||
listproj|lsprj
|
||||
move|mv NUMBER DEST [SRC]
|
||||
prepend|prep NUMBER "TEXT TO PREPEND"
|
||||
pri|p NUMBER PRIORITY
|
||||
replace NUMBER "UPDATED TODO"
|
||||
move|mv ITEM# DEST [SRC]
|
||||
prepend|prep ITEM# "TEXT TO PREPEND"
|
||||
pri|p ITEM# PRIORITY
|
||||
replace ITEM# "UPDATED TODO"
|
||||
report
|
||||
|
||||
See "help" for more details.
|
||||
EndHelp
|
||||
EndHelp
|
||||
exit 0
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
sed -e 's/^ //' <<EndHelp
|
||||
cat <<-EndHelp
|
||||
Usage: $oneline_usage
|
||||
|
||||
Actions:
|
||||
@@ -76,41 +83,48 @@ help()
|
||||
Project and context notation optional.
|
||||
Quotes optional.
|
||||
|
||||
addm "FIRST THING I NEED TO DO +project1 @context
|
||||
SECOND THING I NEED TO DO +project2 @context"
|
||||
Adds FIRST THING I NEED TO DO to your todo.txt on its own line and
|
||||
Adds SECOND THING I NEED TO DO to you todo.txt on its own line.
|
||||
Project and context notation optional.
|
||||
Quotes optional.
|
||||
|
||||
addto DEST "TEXT TO ADD"
|
||||
Adds a line of text to any file located in the todo.txt directory.
|
||||
For example, addto inbox.txt "decide about vacation"
|
||||
|
||||
append NUMBER "TEXT TO APPEND"
|
||||
app NUMBER "TEXT TO APPEND"
|
||||
Adds TEXT TO APPEND to the end of the todo on line NUMBER.
|
||||
append ITEM# "TEXT TO APPEND"
|
||||
app ITEM# "TEXT TO APPEND"
|
||||
Adds TEXT TO APPEND to the end of the task on line ITEM#.
|
||||
Quotes optional.
|
||||
|
||||
archive
|
||||
Moves done items from todo.txt to done.txt and removes blank lines.
|
||||
Moves all done tasks from todo.txt to done.txt and removes blank lines.
|
||||
|
||||
command [ACTIONS]
|
||||
Runs the remaining arguments using only todo.sh builtins.
|
||||
Will not call any .todo.actions.d scripts.
|
||||
|
||||
del NUMBER [TERM]
|
||||
rm NUMBER [TERM]
|
||||
Deletes the item on line NUMBER in todo.txt.
|
||||
If term specified, deletes only the term from the line.
|
||||
del ITEM# [TERM]
|
||||
rm ITEM# [TERM]
|
||||
Deletes the task on line ITEM# in todo.txt.
|
||||
If TERM specified, deletes only TERM from the task.
|
||||
|
||||
depri NUMBER
|
||||
dp NUMBER
|
||||
Deprioritizes (removes the priority) from the item
|
||||
on line NUMBER in todo.txt.
|
||||
depri ITEM#[, ITEM#, ITEM#, ...]
|
||||
dp ITEM#[, ITEM#, ITEM#, ...]
|
||||
Deprioritizes (removes the priority) from the task(s)
|
||||
on line ITEM# in todo.txt.
|
||||
|
||||
do NUMBER
|
||||
Marks item on line NUMBER as done in todo.txt.
|
||||
do ITEM#[, ITEM#, ITEM#, ...]
|
||||
Marks task(s) on line ITEM# as done in todo.txt.
|
||||
|
||||
help
|
||||
Display this help message.
|
||||
|
||||
list [TERM...]
|
||||
ls [TERM...]
|
||||
Displays all todo's that contain TERM(s) sorted by priority with line
|
||||
Displays all tasks that contain TERM(s) sorted by priority with line
|
||||
numbers. If no TERM specified, lists entire todo.txt.
|
||||
|
||||
listall [TERM...]
|
||||
@@ -131,36 +145,36 @@ help()
|
||||
|
||||
listpri [PRIORITY]
|
||||
lsp [PRIORITY]
|
||||
Displays all items prioritized PRIORITY.
|
||||
If no PRIORITY specified, lists all prioritized items.
|
||||
Displays all tasks prioritized PRIORITY.
|
||||
If no PRIORITY specified, lists all prioritized tasks.
|
||||
|
||||
listproj
|
||||
lsprj
|
||||
Lists all the projects that start with the + sign in todo.txt.
|
||||
|
||||
move NUMBER DEST [SRC]
|
||||
mv NUMBER DEST [SRC]
|
||||
move ITEM# DEST [SRC]
|
||||
mv ITEM# DEST [SRC]
|
||||
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
|
||||
in the configuration directory. When SRC is not defined
|
||||
it's by default todo.txt.
|
||||
|
||||
prepend NUMBER "TEXT TO PREPEND"
|
||||
prep NUMBER "TEXT TO PREPEND"
|
||||
Adds TEXT TO PREPEND to the beginning of the todo on line NUMBER.
|
||||
prepend ITEM# "TEXT TO PREPEND"
|
||||
prep ITEM# "TEXT TO PREPEND"
|
||||
Adds TEXT TO PREPEND to the beginning of the task on line ITEM#.
|
||||
Quotes optional.
|
||||
|
||||
pri NUMBER PRIORITY
|
||||
p NUMBER PRIORITY
|
||||
Adds PRIORITY to todo on line NUMBER. If the item is already
|
||||
pri ITEM# PRIORITY
|
||||
p ITEM# PRIORITY
|
||||
Adds PRIORITY to task on line ITEM#. If the task is already
|
||||
prioritized, replaces current priority with new PRIORITY.
|
||||
PRIORITY must be an uppercase letter between A and Z.
|
||||
|
||||
replace NUMBER "UPDATED TODO"
|
||||
Replaces todo on line NUMBER with UPDATED TODO.
|
||||
replace ITEM# "UPDATED TODO"
|
||||
Replaces task on line ITEM# with UPDATED TODO.
|
||||
|
||||
report
|
||||
Adds the number of open todo's and closed done's to report.txt.
|
||||
Adds the number of open tasks and done tasks to report.txt.
|
||||
|
||||
|
||||
|
||||
@@ -172,7 +186,7 @@ help()
|
||||
Hide project names in list output. Use twice to show project
|
||||
names (default).
|
||||
-d CONFIG_FILE
|
||||
Use a configuration file other than the default ~/todo.cfg
|
||||
Use a configuration file other than the default ~/.todo/config
|
||||
-f
|
||||
Forces actions without confirmation or interactive input
|
||||
-h
|
||||
@@ -196,6 +210,8 @@ help()
|
||||
Extra verbose mode prints some debugging information
|
||||
-V
|
||||
Displays version, license and credits
|
||||
-x
|
||||
Disables TODOTXT_FINAL_FILTER
|
||||
|
||||
|
||||
Environment variables:
|
||||
@@ -209,7 +225,7 @@ help()
|
||||
TODOTXT_DEFAULT_ACTION="" run this when called with no arguments
|
||||
TODOTXT_SORT_COMMAND="sort ..." customize list output
|
||||
TODOTXT_FINAL_FILTER="sed ..." customize list after color, P@+ hiding
|
||||
EndHelp
|
||||
EndHelp
|
||||
|
||||
if [ -d "$TODO_ACTIONS_DIR" ]
|
||||
then
|
||||
@@ -237,7 +253,22 @@ die()
|
||||
cleanup()
|
||||
{
|
||||
[ -f "$TMP_FILE" ] && rm "$TMP_FILE"
|
||||
exit 0
|
||||
return 0
|
||||
}
|
||||
|
||||
cleaninput()
|
||||
{
|
||||
# Cleanup the input
|
||||
# Replace newlines with spaces Always
|
||||
input=`echo $input | tr -d '\r|\n'`
|
||||
|
||||
action_regexp="^\(append\|app\|prepend\|prep\|replace\)$"
|
||||
|
||||
# Check which action we are being used in as this affects what cleaning we do
|
||||
if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then
|
||||
# These actions use sed and & as the matched string so escape it
|
||||
input=`echo $input | sed 's/\&/\\\&/g'`
|
||||
fi
|
||||
}
|
||||
|
||||
archive()
|
||||
@@ -248,22 +279,79 @@ archive()
|
||||
grep "^x " "$TODO_FILE" >> "$DONE_FILE"
|
||||
sed -i.bak '/^x /d' "$TODO_FILE"
|
||||
cp "$TODO_FILE" "$TMP_FILE"
|
||||
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
||||
#[[ $TODOTXT_VERBOSE -gt 0 ]] && echo "TODO: Duplicate tasks have been removed."
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $TODO_FILE archived."
|
||||
cleanup
|
||||
sed -n 'G; s/\n/&&/; /^\([ ~-]*\n\).*\n\1/d; s/\n//; h; P' "$TMP_FILE" > "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "TODO: $TODO_FILE archived."
|
||||
fi
|
||||
}
|
||||
|
||||
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 ==
|
||||
while getopts ":fhpnatvV+@Pd:" Option
|
||||
while getopts ":fhpnatvVx+@Pd:" Option
|
||||
do
|
||||
case $Option in
|
||||
'@' )
|
||||
## HIDE_CONTEXT_NAMES starts at zero (false); increment it to one
|
||||
## (true) the first time this flag is seen. Each time the flag
|
||||
## is seen after that, increment it again so that an even
|
||||
## number hides project names and an odd number shows project
|
||||
## number shows context names and an odd number hides context
|
||||
## names.
|
||||
: $(( HIDE_CONTEXT_NAMES++ ))
|
||||
if [ $(( $HIDE_CONTEXT_NAMES % 2 )) -eq 0 ]
|
||||
@@ -279,7 +367,7 @@ do
|
||||
## HIDE_PROJECT_NAMES starts at zero (false); increment it to one
|
||||
## (true) the first time this flag is seen. Each time the flag
|
||||
## is seen after that, increment it again so that an even
|
||||
## number hides project names and an odd number shows project
|
||||
## number shows project names and an odd number hides project
|
||||
## names.
|
||||
: $(( HIDE_PROJECT_NAMES++ ))
|
||||
if [ $(( $HIDE_PROJECT_NAMES % 2 )) -eq 0 ]
|
||||
@@ -313,8 +401,8 @@ do
|
||||
## HIDE_PRIORITY_LABELS starts at zero (false); increment it to one
|
||||
## (true) the first time this flag is seen. Each time the flag
|
||||
## is seen after that, increment it again so that an even
|
||||
## number hides project names and an odd number shows project
|
||||
## names.
|
||||
## number shows priority labels and an odd number hides priority
|
||||
## labels.
|
||||
: $(( HIDE_PRIORITY_LABELS++ ))
|
||||
if [ $(( $HIDE_PRIORITY_LABELS % 2 )) -eq 0 ]
|
||||
then
|
||||
@@ -334,6 +422,9 @@ do
|
||||
V )
|
||||
version
|
||||
;;
|
||||
x )
|
||||
TODOTXT_DISABLE_FILTER=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
@@ -341,7 +432,7 @@ shift $(($OPTIND - 1))
|
||||
# defaults if not yet defined
|
||||
TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1}
|
||||
TODOTXT_PLAIN=${TODOTXT_PLAIN:-0}
|
||||
TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/todo.cfg}
|
||||
TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/.todo/config}
|
||||
TODOTXT_FORCE=${TODOTXT_FORCE:-0}
|
||||
TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1}
|
||||
TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1}
|
||||
@@ -377,7 +468,25 @@ export DEFAULT='\\033[0m'
|
||||
export PRI_A=$YELLOW # color for A priority
|
||||
export PRI_B=$GREEN # color for B priority
|
||||
export PRI_C=$LIGHT_BLUE # color for C priority
|
||||
export PRI_X=$WHITE # color for rest of them
|
||||
export PRI_X=$WHITE # color unless explicitly defined
|
||||
|
||||
# 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" ] || {
|
||||
CFG_FILE_ALT="$HOME/todo.cfg"
|
||||
|
||||
if [ -e "$CFG_FILE_ALT" ]
|
||||
then
|
||||
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
|
||||
fi
|
||||
}
|
||||
|
||||
[ -e "$TODOTXT_CFG_FILE" ] || {
|
||||
CFG_FILE_ALT="$HOME/.todo.cfg"
|
||||
@@ -390,12 +499,21 @@ export PRI_X=$WHITE # color for rest of them
|
||||
|
||||
if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ]
|
||||
then
|
||||
TODO_ACTIONS_DIR="$HOME/.todo.actions.d"
|
||||
TODO_ACTIONS_DIR="$HOME/.todo/actions"
|
||||
export TODO_ACTIONS_DIR
|
||||
fi
|
||||
|
||||
[ -d "$TODO_ACTIONS_DIR" ] || {
|
||||
TODO_ACTIONS_DIR_ALT="$HOME/.todo.actions.d"
|
||||
|
||||
if [ -d "$TODO_ACTIONS_DIR_ALT" ]
|
||||
then
|
||||
TODO_ACTIONS_DIR="$TODO_ACTIONS_DIR_ALT"
|
||||
fi
|
||||
}
|
||||
|
||||
# === 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"
|
||||
|
||||
@@ -411,35 +529,51 @@ ACTION=${1:-$TODOTXT_DEFAULT_ACTION}
|
||||
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
||||
|
||||
if [ $TODOTXT_PLAIN = 1 ]; then
|
||||
PRI_A=$NONE
|
||||
PRI_B=$NONE
|
||||
PRI_C=$NONE
|
||||
for clr in ${!PRI_@}; do
|
||||
export $clr=$NONE
|
||||
done
|
||||
PRI_X=$NONE
|
||||
DEFAULT=$NONE
|
||||
COLOR_DONE=$NONE
|
||||
fi
|
||||
|
||||
# === HEAVY LIFTING ===
|
||||
shopt -s extglob
|
||||
_addto() {
|
||||
file="$1"
|
||||
input="$2"
|
||||
cleaninput $input
|
||||
|
||||
if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
|
||||
now=`date '+%Y-%m-%d'`
|
||||
input="$now $input"
|
||||
fi
|
||||
echo "$input" >> "$file"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
TASKNUM=$(sed -n '$ =' "$file")
|
||||
BASE=$(basename "$file")
|
||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||
echo "$TASKNUM $input"
|
||||
echo "${PREFIX}: $TASKNUM added."
|
||||
fi
|
||||
}
|
||||
|
||||
_list() {
|
||||
local FILE="$1"
|
||||
## If the file starts with a "/" use absolute path. Otherwise,
|
||||
## 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
|
||||
src="$FILE"
|
||||
elif [ -f "$TODO_DIR/$FILE" ]
|
||||
then
|
||||
elif [ -f "$TODO_DIR/$FILE" ]; then
|
||||
## Path relative to todo.sh directory
|
||||
src="$TODO_DIR/$1"
|
||||
elif [ -f "$FILE" ]
|
||||
then
|
||||
src="$TODO_DIR/$FILE"
|
||||
elif [ -f "$FILE" ]; then
|
||||
## Path relative to current working directory
|
||||
src="$FILE"
|
||||
elif [ -f "$TODO_DIR/${FILE}.txt" ]; then
|
||||
## Path relative to todo.sh directory, missing file extension
|
||||
src="$TODO_DIR/${FILE}.txt"
|
||||
else
|
||||
echo "TODO: File $FILE does not exist."
|
||||
exit 1
|
||||
die "TODO: File $FILE does not exist."
|
||||
fi
|
||||
|
||||
## Get our search arguments, if any
|
||||
@@ -448,10 +582,10 @@ _list() {
|
||||
## Prefix the filter_command with the pre_filter_command
|
||||
filter_command="${pre_filter_command:-}"
|
||||
|
||||
for search_term in "$@"
|
||||
for search_term
|
||||
do
|
||||
## See if the first character of $search_term is a dash
|
||||
if [ ${search_term:0:1} != '-' ]
|
||||
if [ "${search_term:0:1}" != '-' ]
|
||||
then
|
||||
## First character isn't a dash: hide lines that don't match
|
||||
## this $search_term
|
||||
@@ -479,10 +613,13 @@ _list() {
|
||||
|
||||
## Number the file, then run the filter command,
|
||||
## then sort and mangle output some more
|
||||
if [[ $TODOTXT_DISABLE_FILTER = 1 ]]; then
|
||||
TODOTXT_FINAL_FILTER="cat"
|
||||
fi
|
||||
items=$(
|
||||
sed = "$src" \
|
||||
| sed "N; s/^/ /; s/ *\(.\{$PADDING,\}\)\n/\1 /" \
|
||||
| grep -v "^[0-9]\+ *$"
|
||||
| grep -v "^[ 0-9]\+ *$"
|
||||
)
|
||||
if [ "${filter_command}" ]; then
|
||||
filtered_items=$(echo -ne "$items" | eval ${filter_command})
|
||||
@@ -500,13 +637,16 @@ _list() {
|
||||
''' \
|
||||
| eval ${TODOTXT_SORT_COMMAND} \
|
||||
| sed '''
|
||||
/^[0-9]\{'$PADDING'\} x /! {
|
||||
s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g;
|
||||
s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g;
|
||||
s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g;
|
||||
s/\(.*([D-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g;
|
||||
}
|
||||
/^[0-9]\{'$PADDING'\} x /s|^.*|'$COLOR_DONE'&'$DEFAULT'|
|
||||
''' \
|
||||
| awk '''{
|
||||
pos = match($0, /\([A-Z]\)/)
|
||||
if( pos > 0 && match($0, /^[0-9]+ x /) != 1 ) {
|
||||
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 '''
|
||||
s/'${HIDE_PRIORITY_SUBSTITUTION:-^}'//g
|
||||
s/'${HIDE_PROJECTS_SUBSTITUTION:-^}'//g
|
||||
@@ -517,19 +657,20 @@ _list() {
|
||||
echo -ne "$filtered_items${filtered_items:+\n}"
|
||||
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
BASE=$(basename "$FILE")
|
||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||
NUMTASKS=$( echo -ne "$filtered_items" | sed -n '$ =' )
|
||||
TOTALTASKS=$( echo -ne "$items" | sed -n '$ =' )
|
||||
|
||||
echo "--"
|
||||
echo "TODO: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown from $FILE"
|
||||
echo "${PREFIX}: ${NUMTASKS:-0} of ${TOTALTASKS:-0} tasks shown"
|
||||
fi
|
||||
if [ $TODOTXT_VERBOSE -gt 1 ]
|
||||
then
|
||||
if [ $TODOTXT_VERBOSE -gt 1 ]; then
|
||||
echo "TODO DEBUG: Filter Command was: ${filter_command:-cat}"
|
||||
fi
|
||||
}
|
||||
|
||||
export -f _list
|
||||
export -f _list die
|
||||
|
||||
# == HANDLE ACTION ==
|
||||
action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' )
|
||||
@@ -547,7 +688,9 @@ then
|
||||
elif [ -d "$TODO_ACTIONS_DIR" -a -x "$TODO_ACTIONS_DIR/$action" ]
|
||||
then
|
||||
"$TODO_ACTIONS_DIR/$action" "$@"
|
||||
status=$?
|
||||
cleanup
|
||||
exit $status
|
||||
fi
|
||||
|
||||
## Only run if $action isn't found in .todo.actions.d
|
||||
@@ -561,15 +704,30 @@ case $action in
|
||||
shift
|
||||
input=$*
|
||||
fi
|
||||
_addto "$TODO_FILE" "$input"
|
||||
;;
|
||||
|
||||
if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
|
||||
now=`date '+%Y-%m-%d'`
|
||||
input="$now $input"
|
||||
"addm")
|
||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||
echo -n "Add: "
|
||||
read input
|
||||
else
|
||||
[ -z "$2" ] && die "usage: $TODO_SH addm \"TODO ITEM\""
|
||||
shift
|
||||
input=$*
|
||||
fi
|
||||
echo "$input" >> "$TODO_FILE"
|
||||
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added on line $TASKNUM."
|
||||
cleanup;;
|
||||
|
||||
# Set Internal Field Seperator as newline so we can
|
||||
# loop across multiple lines
|
||||
SAVEIFS=$IFS
|
||||
IFS=$'\n'
|
||||
|
||||
# Treat each line seperately
|
||||
for line in $input ; do
|
||||
_addto "$TODO_FILE" "$line"
|
||||
done
|
||||
IFS=$SAVEIFS
|
||||
;;
|
||||
|
||||
"addto" )
|
||||
[ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\""
|
||||
@@ -580,13 +738,11 @@ case $action in
|
||||
input=$*
|
||||
|
||||
if [ -f "$dest" ]; then
|
||||
echo "$input" >> "$dest"
|
||||
TASKNUM=$(sed -n '$ =' "$dest")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
||||
_addto "$dest" "$input"
|
||||
else
|
||||
echo "TODO: Destination file $dest does not exist."
|
||||
die "TODO: Destination file $dest does not exist."
|
||||
fi
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"append" | "app" )
|
||||
errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\""
|
||||
@@ -595,36 +751,42 @@ case $action in
|
||||
[ -z "$item" ] && die "$errmsg"
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
[ -z "$todo" ] && die "TODO: No task $item."
|
||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||
echo -n "Append: "
|
||||
read input
|
||||
else
|
||||
input=$*
|
||||
fi
|
||||
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||
case "$input" in
|
||||
[$SENTENCE_DELIMITERS]*) appendspace=;;
|
||||
*) appendspace=" ";;
|
||||
esac
|
||||
cleaninput $input
|
||||
|
||||
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
||||
else
|
||||
echo "TODO: Error appending task $item."
|
||||
echo "$item $newtodo"
|
||||
fi
|
||||
cleanup;;
|
||||
else
|
||||
die "TODO: Error appending task $item."
|
||||
fi
|
||||
;;
|
||||
|
||||
"archive" )
|
||||
archive;;
|
||||
|
||||
"del" | "rm" )
|
||||
# replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $TODO_SH del ITEM#"
|
||||
errmsg="usage: $TODO_SH del ITEM# [TERM]"
|
||||
item=$2
|
||||
[ -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
|
||||
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
|
||||
DELETEME=$(sed "$item!d" "$TODO_FILE")
|
||||
|
||||
if [ $TODOTXT_FORCE = 0 ]; then
|
||||
echo "Delete '$DELETEME'? (y/n)"
|
||||
read ANSWER
|
||||
@@ -639,71 +801,111 @@ case $action in
|
||||
# leave blank line behind (preserves line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
|
||||
fi
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted."
|
||||
cleanup
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "$item $DELETEME"
|
||||
echo "TODO: $item deleted."
|
||||
fi
|
||||
else
|
||||
echo "TODO: No tasks were deleted."
|
||||
fi
|
||||
else
|
||||
echo "$item: No such todo."
|
||||
sed -i.bak \
|
||||
-e $item"s/^\((.) \)\{0,1\} *$3 */\1/g" \
|
||||
-e $item"s/ *$3 *\$//g" \
|
||||
-e $item"s/ *$3 */ /g" \
|
||||
-e $item"s/ *$3 */ /g" \
|
||||
-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
|
||||
else
|
||||
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item."
|
||||
fi ;;
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "$item $DELETEME"
|
||||
echo "TODO: Removed '$3' from task."
|
||||
echo "$item $newtodo"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
"depri" | "dp" )
|
||||
item=$2
|
||||
errmsg="usage: $TODO_SH depri ITEM#"
|
||||
errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]"
|
||||
shift;
|
||||
[ $# -eq 0 ] && die "$errmsg"
|
||||
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
# Split multiple depri's, if comma separated change to whitespace separated
|
||||
# Loop the 'depri' function for each item
|
||||
for item in `echo $* | tr ',' ' '`; do
|
||||
[[ "$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
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
#it's all good, continue
|
||||
sed -i.bak -e $item"s/^(.) //" "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item deprioritized."
|
||||
cleanup
|
||||
echo "$item $NEWTODO"
|
||||
echo "TODO: $item deprioritized."
|
||||
fi
|
||||
else
|
||||
die "$errmsg"
|
||||
fi;;
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
"do" )
|
||||
errmsg="usage: $TODO_SH do ITEM#"
|
||||
item=$2
|
||||
errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]"
|
||||
# shift so we get arguments to the do request
|
||||
shift;
|
||||
[ "$#" -eq 0 ] && die "$errmsg"
|
||||
|
||||
# Split multiple do's, if comma separated change to whitespace separated
|
||||
# Loop the 'do' function for each item
|
||||
for item in `echo $* | tr ',' ' '`; do
|
||||
[ -z "$item" ] && die "$errmsg"
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
[ -z "$todo" ] && die "TODO: No task $item."
|
||||
|
||||
# Check if this item has already been done
|
||||
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
||||
now=`date '+%Y-%m-%d'`
|
||||
# remove priority once item is done
|
||||
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
||||
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item marked as done."
|
||||
echo "$item $newtodo"
|
||||
echo "TODO: $item marked as done."
|
||||
fi
|
||||
else
|
||||
echo "$item is already marked done"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
||||
archive
|
||||
fi
|
||||
cleanup ;;
|
||||
;;
|
||||
|
||||
"help" )
|
||||
help
|
||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
||||
if which "${PAGER:-less}" >/dev/null 2>&1; then
|
||||
# we have a working PAGER (or less as a default)
|
||||
help | "${PAGER:-less}" && exit 0
|
||||
fi
|
||||
fi
|
||||
help # just in case something failed above, we go ahead and just spew to STDOUT
|
||||
;;
|
||||
|
||||
"list" | "ls" )
|
||||
shift ## Was ls; new $1 is first search term
|
||||
_list "$TODO_FILE" "$@"
|
||||
|
||||
cleanup
|
||||
;;
|
||||
|
||||
"listall" | "lsa" )
|
||||
@@ -711,8 +913,6 @@ case $action in
|
||||
|
||||
cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
|
||||
_list "$TMP_FILE" "$@"
|
||||
|
||||
cleanup
|
||||
;;
|
||||
|
||||
"listfile" | "lf" )
|
||||
@@ -721,18 +921,15 @@ case $action in
|
||||
shift ## Was filename; next $1 is first search term
|
||||
|
||||
_list "$FILE" "$@"
|
||||
|
||||
cleanup
|
||||
;;
|
||||
|
||||
"listcon" | "lsc" )
|
||||
grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u
|
||||
cleanup ;;
|
||||
;;
|
||||
|
||||
"listproj" | "lsprj" )
|
||||
grep -o '[^ ]*+[^ ]\+' "$TODO_FILE" | grep '^+' | sort -u
|
||||
cleanup ;;
|
||||
|
||||
;;
|
||||
|
||||
"listpri" | "lsp" )
|
||||
shift ## was "listpri", new $1 is priority to list
|
||||
@@ -766,10 +963,11 @@ case $action in
|
||||
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
|
||||
if [ -f "$src" ]; then
|
||||
if [ -f "$dest" ]; then
|
||||
if sed -ne "$item p" "$src" | grep "^."; then
|
||||
[ -f "$src" ] || die "TODO: Source file $src does not exist."
|
||||
[ -f "$dest" ] || die "TODO: Destination file $dest does not exist."
|
||||
|
||||
MOVEME=$(sed "$item!d" "$src")
|
||||
[ -z "$MOVEME" ] && die "$item: No such item in $src."
|
||||
if [ $TODOTXT_FORCE = 0 ]; then
|
||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||
read ANSWER
|
||||
@@ -786,46 +984,19 @@ case $action in
|
||||
fi
|
||||
echo "$MOVEME" >> "$dest"
|
||||
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||
cleanup
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "$item $MOVEME"
|
||||
echo "TODO: $item moved from '$src' to '$dest'."
|
||||
fi
|
||||
else
|
||||
echo "TODO: No tasks moved."
|
||||
fi
|
||||
else
|
||||
echo "$item: No such item in $src."
|
||||
fi
|
||||
else
|
||||
echo "TODO: Destination file $dest does not exist."
|
||||
fi
|
||||
else
|
||||
echo "TODO: Source file $src does not exist."
|
||||
fi
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"prepend" | "prep" )
|
||||
errmsg="usage: $TODO_SH prepend ITEM# \"TEXT TO 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
|
||||
|
||||
if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
|
||||
else
|
||||
echo "TODO: Error prepending task $item."
|
||||
fi
|
||||
cleanup;;
|
||||
replaceOrPrepend 'prepend' "$@"
|
||||
;;
|
||||
|
||||
"pri" | "p" )
|
||||
item=$2
|
||||
@@ -843,37 +1014,20 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
if [ "$?" -eq 0 ]; then
|
||||
#it's all good, continue
|
||||
sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE"
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item prioritized ($newpri)."
|
||||
cleanup
|
||||
echo "$item $NEWTODO"
|
||||
echo "TODO: $item prioritized ($newpri)."
|
||||
fi
|
||||
else
|
||||
die "$errmsg"
|
||||
fi;;
|
||||
fi
|
||||
;;
|
||||
|
||||
"replace" )
|
||||
errmsg="usage: $TODO_SH replace ITEM# \"UPDATED ITEM\""
|
||||
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 "Replacement: "
|
||||
read input
|
||||
else
|
||||
input=$*
|
||||
fi
|
||||
|
||||
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $todo"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "replaced with"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $NEWTODO"
|
||||
cleanup;;
|
||||
replaceOrPrepend 'replace' "$@"
|
||||
;;
|
||||
|
||||
"report" )
|
||||
#archive first
|
||||
@@ -892,9 +1046,10 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
echo $TECHO >> "$REPORT_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
||||
cat "$REPORT_FILE"
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
* )
|
||||
usage
|
||||
;;
|
||||
usage;;
|
||||
esac
|
||||
|
||||
cleanup
|
||||
|
||||
Reference in New Issue
Block a user