Compare commits
52 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 |
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -1,6 +0,0 @@
|
||||
.git[ia]* export-ignore
|
||||
GEN-VERSION-FILE export-ignore
|
||||
Makefile export-ignore
|
||||
README.textile export-ignore
|
||||
VERSION-FILE export-ignore
|
||||
tests export-ignore
|
||||
@@ -10,7 +10,7 @@ to find it somewhere else.
|
||||
|
||||
# Remove the pre-created todo.cfg to test behavior in its absence
|
||||
rm -f todo.cfg
|
||||
echo "Fatal error: Cannot read configuration file $HOME/.todo/config" > expect
|
||||
echo "Fatal Error: Cannot read configuration file $HOME/.todo/config" > expect
|
||||
test_expect_success 'no config file' '
|
||||
todo.sh > output 2>&1 || test_cmp expect output
|
||||
'
|
||||
|
||||
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,7 +12,8 @@ command work, including support for filtering.
|
||||
#
|
||||
test_todo_session 'basic add/list' <<EOF
|
||||
>>> todo.sh add notice the daisies
|
||||
TODO: 'notice the daisies' added on line 1.
|
||||
1 notice the daisies
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies
|
||||
@@ -20,7 +21,8 @@ TODO: 'notice the daisies' added on line 1.
|
||||
TODO: 1 of 1 tasks shown
|
||||
|
||||
>>> todo.sh add smell the roses
|
||||
TODO: 'smell the roses' added on line 2.
|
||||
2 smell the roses
|
||||
TODO: 2 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies
|
||||
@@ -46,7 +48,8 @@ EOF
|
||||
|
||||
test_todo_session 'case-insensitive filtering' <<EOF
|
||||
>>> todo.sh add smell the uppercase Roses
|
||||
TODO: 'smell the uppercase Roses' added on line 3.
|
||||
3 smell the uppercase Roses
|
||||
TODO: 3 added.
|
||||
|
||||
>>> todo.sh list roses
|
||||
2 smell the roses
|
||||
@@ -57,7 +60,8 @@ EOF
|
||||
|
||||
test_todo_session 'add with &' <<EOF
|
||||
>>> todo.sh add "dig the garden & water the flowers"
|
||||
TODO: 'dig the garden & water the flowers' added on line 4.
|
||||
4 dig the garden & water the flowers
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh list
|
||||
4 dig the garden & water the flowers
|
||||
|
||||
@@ -12,7 +12,8 @@ a date to each item.
|
||||
#
|
||||
test_todo_session 'cmd line first day' <<EOF
|
||||
>>> todo.sh -t add notice the daisies
|
||||
TODO: '2009-02-13 notice the daisies' added on line 1.
|
||||
1 2009-02-13 notice the daisies
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -24,7 +25,8 @@ test_tick
|
||||
|
||||
test_todo_session 'cmd line second day' <<EOF
|
||||
>>> todo.sh -t add smell the roses
|
||||
TODO: '2009-02-14 smell the roses' added on line 2.
|
||||
2 2009-02-14 smell the roses
|
||||
TODO: 2 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -37,7 +39,8 @@ test_tick
|
||||
|
||||
test_todo_session 'cmd line third day' <<EOF
|
||||
>>> todo.sh -t add mow the lawn
|
||||
TODO: '2009-02-15 mow the lawn' added on line 3.
|
||||
3 2009-02-15 mow the lawn
|
||||
TODO: 3 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -55,7 +58,8 @@ test_tick 3600
|
||||
|
||||
test_todo_session 'config file third day' <<EOF
|
||||
>>> todo.sh add take out the trash
|
||||
TODO: '2009-02-15 take out the trash' added on line 4.
|
||||
4 2009-02-15 take out the trash
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh list
|
||||
1 2009-02-13 notice the daisies
|
||||
|
||||
@@ -13,13 +13,15 @@ commands work, including support for filtering.
|
||||
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
|
||||
GARDEN: 'notice the daisies' added on line 1.
|
||||
1 notice the daisies
|
||||
GARDEN: 1 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 notice the daisies
|
||||
@@ -27,7 +29,8 @@ GARDEN: 'notice the daisies' added on line 1.
|
||||
GARDEN: 1 of 1 tasks shown
|
||||
|
||||
>>> todo.sh addto garden.txt smell the roses
|
||||
GARDEN: 'smell the roses' added on line 2.
|
||||
2 smell the roses
|
||||
GARDEN: 2 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 notice the daisies
|
||||
@@ -53,7 +56,8 @@ EOF
|
||||
|
||||
test_todo_session 'case-insensitive filtering' <<EOF
|
||||
>>> todo.sh addto garden.txt smell the uppercase Roses
|
||||
GARDEN: 'smell the uppercase Roses' added on line 3.
|
||||
3 smell the uppercase Roses
|
||||
GARDEN: 3 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt roses
|
||||
2 smell the roses
|
||||
@@ -64,7 +68,8 @@ EOF
|
||||
|
||||
test_todo_session 'addto with &' <<EOF
|
||||
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
|
||||
GARDEN: 'dig the garden & water the flowers' added on line 4.
|
||||
4 dig the garden & water the flowers
|
||||
GARDEN: 4 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
4 dig the garden & water the flowers
|
||||
|
||||
@@ -14,7 +14,8 @@ touch "$HOME/garden.txt"
|
||||
#
|
||||
test_todo_session 'cmd line first day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt notice the daisies
|
||||
GARDEN: '2009-02-13 notice the daisies' added on line 1.
|
||||
1 2009-02-13 notice the daisies
|
||||
GARDEN: 1 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -26,7 +27,8 @@ test_tick
|
||||
|
||||
test_todo_session 'cmd line second day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt smell the roses
|
||||
GARDEN: '2009-02-14 smell the roses' added on line 2.
|
||||
2 2009-02-14 smell the roses
|
||||
GARDEN: 2 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -39,7 +41,8 @@ test_tick
|
||||
|
||||
test_todo_session 'cmd line third day' <<EOF
|
||||
>>> todo.sh -t addto garden.txt mow the lawn
|
||||
GARDEN: '2009-02-15 mow the lawn' added on line 3.
|
||||
3 2009-02-15 mow the lawn
|
||||
GARDEN: 3 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
@@ -57,7 +60,8 @@ test_tick 3600
|
||||
|
||||
test_todo_session 'config file third day' <<EOF
|
||||
>>> todo.sh addto garden.txt take out the trash
|
||||
GARDEN: '2009-02-15 take out the trash' added on line 4.
|
||||
4 2009-02-15 take out the trash
|
||||
GARDEN: 4 added.
|
||||
|
||||
>>> todo.sh listfile garden.txt
|
||||
1 2009-02-13 notice the daisies
|
||||
|
||||
@@ -19,9 +19,9 @@ 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
|
||||
@@ -29,9 +29,9 @@ replaced with
|
||||
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
|
||||
@@ -47,42 +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
|
||||
4 (A) collect the eggs
|
||||
TODO: 4 prioritized (A).
|
||||
|
||||
>>> todo.sh replace 4 "collect the bread"
|
||||
4: (A) collect the eggs
|
||||
replaced with
|
||||
4: (A) 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
|
||||
replaced with
|
||||
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
|
||||
|
||||
@@ -25,7 +25,7 @@ test_todo_session 'basic priority' <<EOF
|
||||
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
|
||||
@@ -43,7 +43,7 @@ TODO: 3 of 3 tasks shown
|
||||
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
|
||||
@@ -54,7 +54,7 @@ TODO: 2 prioritized (C).
|
||||
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
|
||||
@@ -65,7 +65,7 @@ TODO: 2 prioritized (A).
|
||||
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
|
||||
@@ -75,7 +75,8 @@ TODO: 2 prioritized (A).
|
||||
TODO: 2 of 3 tasks shown
|
||||
|
||||
>>> todo.sh add "smell the coffee +wakeup"
|
||||
TODO: 'smell the coffee +wakeup' added on line 4.
|
||||
4 smell the coffee +wakeup
|
||||
TODO: 4 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
2 (A) notice the sunflowers
|
||||
|
||||
@@ -53,6 +53,47 @@ test_todo_session 'checking TODOTXT_FINAL_FILTER' <<EOF
|
||||
TODO: 3 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the filtering of TERM
|
||||
#
|
||||
test_todo_session 'checking filtering of TERM' <<EOF
|
||||
>>> todo.sh ls second
|
||||
3 bbb yyy this line should be second.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "should be f"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls " zzz"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the filtering of TERM with regexp
|
||||
#
|
||||
test_todo_session 'checking filtering of TERM with regexp' <<EOF
|
||||
>>> todo.sh ls "ir[ds]"
|
||||
2 aaa zzz this line should be first.
|
||||
1 ccc xxx this line should be third.
|
||||
--
|
||||
TODO: 2 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "f.*t"
|
||||
2 aaa zzz this line should be first.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
|
||||
>>> todo.sh ls "ir[ds]" xxx
|
||||
1 ccc xxx this line should be third.
|
||||
--
|
||||
TODO: 1 of 3 tasks shown
|
||||
EOF
|
||||
|
||||
#
|
||||
# check the x command line option
|
||||
#
|
||||
|
||||
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
|
||||
@@ -31,7 +31,7 @@ TODO: 3 of 3 tasks shown
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh prepend 2 test
|
||||
2: test notice the sunflowers
|
||||
2 test notice the sunflowers
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -41,7 +41,7 @@ TODO: 3 of 3 tasks shown
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> todo.sh prepend 1 test
|
||||
1: (B) test smell the uppercase Roses +flowers @outside
|
||||
1 (B) test smell the uppercase Roses +flowers @outside
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) test smell the uppercase Roses +flowers @outside
|
||||
@@ -54,7 +54,41 @@ EOF
|
||||
|
||||
test_todo_session 'prepend with &' <<EOF
|
||||
>>> todo.sh prepend 3 "no running & jumping now"
|
||||
3: no running & jumping now stop
|
||||
3 no running & jumping now stop
|
||||
EOF
|
||||
|
||||
cat /dev/null > todo.txt
|
||||
test_todo_session 'prepend handling prepended date on add' <<EOF
|
||||
>>> todo.sh -t add "new task"
|
||||
1 2009-02-13 new task
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh prepend 1 "this is just a"
|
||||
1 2009-02-13 this is just a new task
|
||||
EOF
|
||||
|
||||
cat /dev/null > todo.txt
|
||||
test_todo_session 'prepend handling priority and prepended date on add' <<EOF
|
||||
>>> todo.sh -t add "new task"
|
||||
1 2009-02-13 new task
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh pri 1 A
|
||||
1 (A) 2009-02-13 new task
|
||||
TODO: 1 prioritized (A).
|
||||
|
||||
>>> todo.sh prepend 1 "this is just a"
|
||||
1 (A) 2009-02-13 this is just a new task
|
||||
EOF
|
||||
|
||||
cat /dev/null > todo.txt
|
||||
test_todo_session 'prepend with prepended date keeps both' <<EOF
|
||||
>>> todo.sh -t add "new task"
|
||||
1 2009-02-13 new task
|
||||
TODO: 1 added.
|
||||
|
||||
>>> todo.sh prepend 1 "2010-07-04 this is just a"
|
||||
1 2009-02-13 2010-07-04 this is just a new task
|
||||
EOF
|
||||
|
||||
test_done
|
||||
|
||||
@@ -8,7 +8,13 @@ test_description='do functionality
|
||||
|
||||
test_todo_session 'do usage' <<EOF
|
||||
>>> todo.sh do B B
|
||||
usage: todo.sh do ITEM#
|
||||
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
|
||||
|
||||
@@ -35,9 +41,9 @@ test_todo_session 'basic do' <<EOF
|
||||
TODO: 7 of 7 tasks shown
|
||||
|
||||
>>> todo.sh do 7,6
|
||||
7: x 2009-02-13 remove4
|
||||
7 x 2009-02-13 remove4
|
||||
TODO: 7 marked as done.
|
||||
6: x 2009-02-13 remove3
|
||||
6 x 2009-02-13 remove3
|
||||
TODO: 6 marked as done.
|
||||
x 2009-02-13 remove3
|
||||
x 2009-02-13 remove4
|
||||
@@ -53,9 +59,9 @@ TODO: $HOME/todo.txt archived.
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh do 5 4
|
||||
5: x 2009-02-13 remove2
|
||||
5 x 2009-02-13 remove2
|
||||
TODO: 5 marked as done.
|
||||
4: x 2009-02-13 remove1
|
||||
4 x 2009-02-13 remove1
|
||||
TODO: 4 marked as done.
|
||||
x 2009-02-13 remove1
|
||||
x 2009-02-13 remove2
|
||||
@@ -71,7 +77,7 @@ EOF
|
||||
|
||||
test_todo_session 'fail multiple do attempts' <<EOF
|
||||
>>> todo.sh -a do 3
|
||||
3: x 2009-02-13 stop
|
||||
3 x 2009-02-13 stop
|
||||
TODO: 3 marked as done.
|
||||
|
||||
>>> todo.sh -a do 3
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='done functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
#DATE=`date '+%Y-%m-%d'`
|
||||
|
||||
test_todo_session 'done usage' <<EOF
|
||||
>>> export TODOTXT_FORCE=1
|
||||
|
||||
>>> todo.sh done
|
||||
usage: todo.sh done "TODO ITEM"
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
cat > todo.txt <<EOF
|
||||
stop
|
||||
remove1
|
||||
remove2
|
||||
remove3
|
||||
remove4
|
||||
EOF
|
||||
|
||||
test_todo_session 'basic done' <<EOF
|
||||
>>> todo.sh lsa
|
||||
2 remove1
|
||||
3 remove2
|
||||
4 remove3
|
||||
5 remove4
|
||||
1 stop
|
||||
--
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh done smell the uppercase Roses
|
||||
TODO: 'smell the uppercase Roses' marked as done.
|
||||
|
||||
>>> todo.sh done notice the sunflowers
|
||||
TODO: 'notice the sunflowers' marked as done.
|
||||
|
||||
>>> todo.sh lsa
|
||||
2 remove1
|
||||
3 remove2
|
||||
4 remove3
|
||||
5 remove4
|
||||
1 stop
|
||||
7 x 2009-02-13 notice the sunflowers
|
||||
6 x 2009-02-13 smell the uppercase Roses
|
||||
--
|
||||
TODO: 7 of 7 tasks shown
|
||||
EOF
|
||||
test_done
|
||||
@@ -19,7 +19,7 @@ EOF
|
||||
|
||||
test_todo_session 'basic append' <<EOF
|
||||
>>> todo.sh append 1 "smell the roses"
|
||||
1: notice the daisies smell the roses
|
||||
1 notice the daisies smell the roses
|
||||
|
||||
>>> todo.sh list
|
||||
1 notice the daisies smell the roses
|
||||
@@ -29,7 +29,7 @@ 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
|
||||
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
|
||||
@@ -41,7 +41,36 @@ EOF
|
||||
test_todo_session 'append error' << EOF
|
||||
>>> todo.sh append 10 "hej!"
|
||||
=== 1
|
||||
10: No such todo.
|
||||
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
|
||||
@@ -6,9 +6,9 @@ test_description='Multi-line functionality'
|
||||
|
||||
## Replace test
|
||||
# Create the expected file
|
||||
echo "1: smell the cheese
|
||||
replaced with
|
||||
1: eat apples eat oranges drink milk">$HOME/expect.multi
|
||||
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' '
|
||||
(
|
||||
@@ -33,7 +33,8 @@ fi
|
||||
|
||||
## Add test
|
||||
# Create the expected file
|
||||
echo "TODO: 'eat apples eat oranges drink milk' added on line 2.">$HOME/expect.multi
|
||||
echo "2 eat apples eat oranges drink milk
|
||||
TODO: 2 added.">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item add' '
|
||||
(
|
||||
@@ -58,7 +59,7 @@ fi
|
||||
|
||||
## Append test
|
||||
# Create the expected file
|
||||
echo "1: smell the cheese eat apples eat oranges drink milk">$HOME/expect.multi
|
||||
echo "1 smell the cheese eat apples eat oranges drink milk">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item append' '
|
||||
(
|
||||
@@ -83,7 +84,7 @@ fi
|
||||
|
||||
## Prepend test
|
||||
# Create the expected file
|
||||
echo "1: eat apples eat oranges drink milk smell the cheese">$HOME/expect.multi
|
||||
echo "1 eat apples eat oranges drink milk smell the cheese">$HOME/expect.multi
|
||||
|
||||
test_expect_success 'multiline squash item prepend' '
|
||||
(
|
||||
@@ -108,9 +109,12 @@ fi
|
||||
|
||||
## Multiple line addition
|
||||
# Create the expected file
|
||||
echo "TODO: 'eat apples' added on line 2." > $HOME/expect.multi
|
||||
echo "TODO: 'eat oranges' added on line 3." >>$HOME/expect.multi
|
||||
echo "TODO: 'drink milk' added on line 4." >> $HOME/expect.multi
|
||||
echo "2 eat apples
|
||||
TODO: 2 added." > $HOME/expect.multi
|
||||
echo "3 eat oranges
|
||||
TODO: 3 added." >>$HOME/expect.multi
|
||||
echo "4 drink milk
|
||||
TODO: 4 added." >> $HOME/expect.multi
|
||||
|
||||
test_expect_success 'actual multiline add' '
|
||||
(
|
||||
|
||||
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
|
||||
@@ -36,7 +36,7 @@ TODO: 2 of 4 tasks shown
|
||||
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
|
||||
@@ -48,7 +48,8 @@ TODO: 2 marked as done.
|
||||
TODO: 4 of 4 tasks shown
|
||||
|
||||
>>> todo.sh add "make the coffee +wakeup"
|
||||
TODO: 'make the coffee +wakeup' added on line 5.
|
||||
5 make the coffee +wakeup
|
||||
TODO: 5 added.
|
||||
|
||||
>>> todo.sh -p list coffee
|
||||
5 make the coffee +wakeup
|
||||
@@ -57,7 +58,8 @@ TODO: 'make the coffee +wakeup' added on line 5.
|
||||
TODO: 2 of 5 tasks shown
|
||||
|
||||
>>> todo.sh add "visit http://example.com"
|
||||
TODO: 'visit http://example.com' added on line 6.
|
||||
6 visit http://example.com
|
||||
TODO: 6 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -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
|
||||
@@ -108,7 +110,7 @@ usage: todo.sh append ITEM# "TEXT TO APPEND"
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh append 10 "hej!"
|
||||
10: No such todo.
|
||||
TODO: No task 10.
|
||||
=== 1
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -121,7 +123,7 @@ TODO: 5 of 5 tasks shown
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh do 10
|
||||
10: No such todo.
|
||||
TODO: No task 10.
|
||||
=== 1
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -134,7 +136,8 @@ TODO: 5 of 5 tasks shown
|
||||
TODO: 5 of 5 tasks shown
|
||||
|
||||
>>> todo.sh add "the coffee +wakeup"
|
||||
TODO: 'the coffee +wakeup' added on line 6.
|
||||
6 the coffee +wakeup
|
||||
TODO: 6 added.
|
||||
|
||||
>>> todo.sh -p list
|
||||
1 (B) smell the uppercase Roses +flowers @outside
|
||||
@@ -147,7 +150,7 @@ TODO: 'the coffee +wakeup' added on line 6.
|
||||
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
|
||||
|
||||
@@ -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 ===
|
||||
|
||||
|
||||
629
todo.sh
629
todo.sh
@@ -1,5 +1,8 @@
|
||||
#! /bin/bash
|
||||
|
||||
# === 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.
|
||||
|
||||
@@ -44,12 +47,12 @@ shorthelp()
|
||||
addto DEST "TEXT TO ADD"
|
||||
addm "THINGS I NEED TO DO
|
||||
MORE THINGS I NEED TO DO"
|
||||
append|app NUMBER "TEXT TO APPEND"
|
||||
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...]
|
||||
@@ -57,10 +60,10 @@ 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.
|
||||
@@ -91,37 +94,37 @@ help()
|
||||
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[, NUMBER, NUMBER, ...]
|
||||
Marks item(s) 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...]
|
||||
@@ -142,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.
|
||||
|
||||
|
||||
|
||||
@@ -250,7 +253,7 @@ die()
|
||||
cleanup()
|
||||
{
|
||||
[ -f "$TMP_FILE" ] && rm "$TMP_FILE"
|
||||
exit 0
|
||||
return 0
|
||||
}
|
||||
|
||||
cleaninput()
|
||||
@@ -277,13 +280,68 @@ archive()
|
||||
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."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $TODO_FILE archived." $TODO_FILE $DONE_FILE
|
||||
cleanup
|
||||
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 ":fhpnatvVx+@Pd:" Option
|
||||
@@ -382,8 +440,6 @@ TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
||||
TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-}
|
||||
TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2}
|
||||
TODOTXT_FINAL_FILTER=${TODOTXT_FINAL_FILTER:-cat}
|
||||
TODOTXT_GIT_ENABLED=${TODOTXT_GIT_ENABLED:-1}
|
||||
TODOTXT_GIT_VERBOSE=${TODOTXT_GIT_VERBOSE:-0}
|
||||
|
||||
# Export all TODOTXT_* variables
|
||||
export ${!TODOTXT_@}
|
||||
@@ -412,7 +468,16 @@ 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"
|
||||
@@ -448,7 +513,7 @@ 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"
|
||||
|
||||
@@ -464,16 +529,14 @@ 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"
|
||||
@@ -484,69 +547,33 @@ _addto() {
|
||||
input="$now $input"
|
||||
fi
|
||||
echo "$input" >> "$file"
|
||||
|
||||
( [ $TODOTXT_VERBOSE -gt 0 ] || [ $TODOTXT_GIT_ENABLED -eq 1 ] ) && {
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
TASKNUM=$(sed -n '$ =' "$file")
|
||||
BASE=$(basename "$file")
|
||||
PREFIX=$(echo ${BASE%%.[^.]*} | tr [a-z] [A-Z])
|
||||
MESG="${PREFIX}: '$input' added on line $TASKNUM."
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && \
|
||||
echo $MESG
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "$MESG" $file
|
||||
}
|
||||
}
|
||||
|
||||
_commit() {
|
||||
[ -z "$1" ] && die "Fatal Error: No commit message."
|
||||
[ -z "$2" ] && die "Fatal Error: No commit files."
|
||||
MESG="$(echo $1 | sed -e 's|\\n|\n|g')"
|
||||
shift
|
||||
FILES=$*
|
||||
|
||||
if [ $TODOTXT_GIT_VERBOSE -eq 0 ] ; then
|
||||
( cd $TODO_DIR
|
||||
for file in $FILES ; do
|
||||
BASE=$(basename $file)
|
||||
git add $BASE > /dev/null 2>&1
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git add $BASE failed."
|
||||
done
|
||||
git commit -m "$MESG" > /dev/null 2>&1
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git commit failed."
|
||||
)
|
||||
else
|
||||
( cd $TODO_DIR
|
||||
for file in $FILES ; do
|
||||
BASE=$(basename $file)
|
||||
git add $BASE
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git add $BASE failed."
|
||||
done
|
||||
git commit -m "$MESG"
|
||||
[ "$?" != 0 ] && die "Fatal Error: Git commit failed."
|
||||
)
|
||||
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
|
||||
@@ -555,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
|
||||
@@ -610,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
|
||||
@@ -635,13 +665,12 @@ _list() {
|
||||
echo "--"
|
||||
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' )
|
||||
@@ -659,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
|
||||
@@ -674,7 +705,7 @@ case $action in
|
||||
input=$*
|
||||
fi
|
||||
_addto "$TODO_FILE" "$input"
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"addm")
|
||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||
@@ -696,7 +727,7 @@ case $action in
|
||||
_addto "$TODO_FILE" "$line"
|
||||
done
|
||||
IFS=$SAVEIFS
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"addto" )
|
||||
[ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\""
|
||||
@@ -709,9 +740,9 @@ case $action in
|
||||
if [ -f "$dest" ]; then
|
||||
_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\""
|
||||
@@ -720,121 +751,126 @@ 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
|
||||
case "$input" in
|
||||
[$SENTENCE_DELIMITERS]*) appendspace=;;
|
||||
*) appendspace=" ";;
|
||||
esac
|
||||
cleaninput $input
|
||||
|
||||
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
if sed -i.bak $item" s|^.*|&${appendspace}${input}|" "$TODO_FILE"; then
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Appended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
echo "$item $newtodo"
|
||||
fi
|
||||
else
|
||||
echo "TODO: Error appending task $item."
|
||||
die "TODO: Error appending task $item."
|
||||
fi
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"archive" )
|
||||
archive;;
|
||||
|
||||
"commit" )
|
||||
[ -z "$2" ] && die "usage: $TODO_SH commit MESSAGE"
|
||||
shift
|
||||
MESG=$*
|
||||
|
||||
( cd $TODO_DIR
|
||||
git commit -a -m "$MESG"
|
||||
);;
|
||||
|
||||
"del" | "rm" )
|
||||
# replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $TODO_SH del ITEM#"
|
||||
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
|
||||
if [ $TODOTXT_FORCE = 0 ]; then
|
||||
echo "Delete '$DELETEME'? (y/n)"
|
||||
read ANSWER
|
||||
else
|
||||
ANSWER="y"
|
||||
fi
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE"
|
||||
else
|
||||
ANSWER="y"
|
||||
# leave blank line behind (preserves line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
|
||||
fi
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE"
|
||||
else
|
||||
# leave blank line behind (preserves line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" "$TODO_FILE"
|
||||
fi
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$DELETEME' deleted." $TODO_FILE
|
||||
cleanup
|
||||
else
|
||||
echo "TODO: No tasks were deleted."
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "$item $DELETEME"
|
||||
echo "TODO: $item deleted."
|
||||
fi
|
||||
else
|
||||
echo "$item: No such todo."
|
||||
echo "TODO: No tasks were deleted."
|
||||
fi
|
||||
else
|
||||
sed -i.bak -e $item"s/$3/ /g" "$TODO_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $3 removed from $item."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $3 removed from $item." $TODO_FILE
|
||||
fi ;;
|
||||
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
|
||||
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."
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
# 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
|
||||
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"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "`echo "$item: $NEWTODO"`"
|
||||
echo "TODO: $item deprioritized."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$todo' deprioritized." $TODO_FILE
|
||||
cleanup
|
||||
else
|
||||
die "$errmsg"
|
||||
fi;;
|
||||
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")
|
||||
echo "$item $NEWTODO"
|
||||
echo "TODO: $item deprioritized."
|
||||
fi
|
||||
else
|
||||
die "$errmsg"
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
"do" )
|
||||
errmsg="usage: $TODO_SH do ITEM#"
|
||||
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 seperated change to whitespace sepereated
|
||||
# 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
|
||||
@@ -842,13 +878,11 @@ case $action in
|
||||
# remove priority once item is done
|
||||
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
||||
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
echo "$item $newtodo"
|
||||
echo "TODO: $item marked as done."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$todo' marked as done." $TODO_FILE
|
||||
fi
|
||||
else
|
||||
echo "$item is already marked done"
|
||||
fi
|
||||
@@ -857,35 +891,13 @@ case $action in
|
||||
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
||||
archive
|
||||
fi
|
||||
cleanup ;;
|
||||
|
||||
"done" )
|
||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||
echo -n "Done: "
|
||||
read input
|
||||
else
|
||||
[ -z "$2" ] && die "usage: $TODO_SH done \"TODO ITEM\""
|
||||
shift
|
||||
input=$*
|
||||
fi
|
||||
|
||||
now=`date '+%Y-%m-%d'`
|
||||
# remove priority once item is done
|
||||
newtodo=$(sed -e "s/^(.) // ; s|^|&x $now |" <<<${input})
|
||||
echo "$newtodo" >> "$DONE_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
echo "TODO: '$input' marked as done."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$input' marked as done." $DONE_FILE
|
||||
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
"help" )
|
||||
if [ -t 1 ] ; then # STDOUT is a TTY
|
||||
if (exec which ${PAGER:-less} 2>/dev/null >/dev/null); then
|
||||
if which "${PAGER:-less}" >/dev/null 2>&1; then
|
||||
# we have a working PAGER (or less as a default)
|
||||
help | exec ${PAGER:-less}
|
||||
help | "${PAGER:-less}" && exit 0
|
||||
fi
|
||||
fi
|
||||
help # just in case something failed above, we go ahead and just spew to STDOUT
|
||||
@@ -894,8 +906,6 @@ case $action in
|
||||
"list" | "ls" )
|
||||
shift ## Was ls; new $1 is first search term
|
||||
_list "$TODO_FILE" "$@"
|
||||
|
||||
cleanup
|
||||
;;
|
||||
|
||||
"listall" | "lsa" )
|
||||
@@ -903,8 +913,6 @@ case $action in
|
||||
|
||||
cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
|
||||
_list "$TMP_FILE" "$@"
|
||||
|
||||
cleanup
|
||||
;;
|
||||
|
||||
"listfile" | "lf" )
|
||||
@@ -913,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
|
||||
@@ -945,11 +950,6 @@ case $action in
|
||||
_list "$TODO_FILE" "$pri"
|
||||
;;
|
||||
|
||||
"log" | "pull" | "push" )
|
||||
( cd $TODO_DIR
|
||||
git $action
|
||||
);;
|
||||
|
||||
"move" | "mv" )
|
||||
# replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]"
|
||||
@@ -963,96 +963,40 @@ case $action in
|
||||
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
|
||||
if [ -f "$src" ]; then
|
||||
if [ -f "$dest" ]; then
|
||||
if sed -ne "$item p" "$src" | grep "^."; then
|
||||
MOVEME=$(sed "$item!d" "$src")
|
||||
if [ $TODOTXT_FORCE = 0 ]; then
|
||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||
read ANSWER
|
||||
else
|
||||
ANSWER="y"
|
||||
fi
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$src"
|
||||
else
|
||||
# leave blank line behind (preserves line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" "$src"
|
||||
fi
|
||||
echo "$MOVEME" >> "$dest"
|
||||
[ -f "$src" ] || die "TODO: Source file $src does not exist."
|
||||
[ -f "$dest" ] || die "TODO: Destination file $dest does not exist."
|
||||
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: '$MOVEME' moved from '$src' to '$dest'." \
|
||||
$src $dest
|
||||
cleanup
|
||||
else
|
||||
echo "TODO: No tasks moved."
|
||||
fi
|
||||
else
|
||||
echo "$item: No such item in $src."
|
||||
fi
|
||||
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
|
||||
else
|
||||
ANSWER="y"
|
||||
fi
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" -e '/./!d' "$src"
|
||||
else
|
||||
echo "TODO: Destination file $dest does not exist."
|
||||
# leave blank line behind (preserves line numbers)
|
||||
sed -i.bak -e $item"s/^.*//" "$src"
|
||||
fi
|
||||
echo "$MOVEME" >> "$dest"
|
||||
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
echo "$item $MOVEME"
|
||||
echo "TODO: $item moved from '$src' to '$dest'."
|
||||
fi
|
||||
else
|
||||
echo "TODO: Source file $src does not exist."
|
||||
echo "TODO: No tasks moved."
|
||||
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
|
||||
cleaninput $input
|
||||
|
||||
# Test for then set priority
|
||||
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||
priority=$(sed "$item!d" "$TODO_FILE" | awk -F '\\(|\\)' '{print $2}')
|
||||
fi
|
||||
|
||||
# If priority isn't set prepend
|
||||
if [ -z $priority ]; then
|
||||
if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Prepended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
else
|
||||
echo "TODO: Error prepending task $item."
|
||||
fi
|
||||
# If priority is set, remove priority, prepend and add back priority
|
||||
else
|
||||
if sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1 &|" "$TODO_FILE"; then
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "$item: $newtodo"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Prepended '$todo' w/ '$input' on line $item." \
|
||||
$TODO_FILE
|
||||
else
|
||||
echo "TODO: Error prepending task $item."
|
||||
fi
|
||||
fi
|
||||
cleanup;;
|
||||
replaceOrPrepend 'prepend' "$@"
|
||||
;;
|
||||
|
||||
"pri" | "p" )
|
||||
item=$2
|
||||
@@ -1070,56 +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"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
if [ $TODOTXT_VERBOSE -gt 0 ]; then
|
||||
NEWTODO=$(sed "$item!d" "$TODO_FILE")
|
||||
echo "`echo "$item: $NEWTODO"`"
|
||||
echo "$item $NEWTODO"
|
||||
echo "TODO: $item prioritized ($newpri)."
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: $item prioritized ($newpri)." $TODO_FILE
|
||||
cleanup
|
||||
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."
|
||||
|
||||
# Test for then set priority
|
||||
if [ `sed "$item!d" "$TODO_FILE"|grep -c "^(\\w)"` -eq 1 ]; then
|
||||
priority=$(sed "$item!d" "$TODO_FILE" | awk -F '\\(|\\)' '{print $2}')
|
||||
fi
|
||||
|
||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||
echo -n "Replacement: "
|
||||
read input
|
||||
else
|
||||
input=$*
|
||||
fi
|
||||
cleaninput $input
|
||||
|
||||
# If priority isn't set replace, if it is remove priority, replace then add priority again
|
||||
if [ -z $priority ]; then
|
||||
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
||||
else
|
||||
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
||||
fi
|
||||
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||
echo "$item: $todo"
|
||||
echo "replaced with"
|
||||
echo "$item: $NEWTODO"
|
||||
}
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "$item: $todo\nreplaced with\n$item: $NEWTODO" $TODO_FILE
|
||||
cleanup;;
|
||||
replaceOrPrepend 'replace' "$@"
|
||||
;;
|
||||
|
||||
"report" )
|
||||
#archive first
|
||||
@@ -1137,12 +1045,11 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
echo ${TDONE:-0})
|
||||
echo $TECHO >> "$REPORT_FILE"
|
||||
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: Report file updated."
|
||||
[ $TODOTXT_GIT_ENABLED -eq 1 ] && \
|
||||
_commit "TODO: Report file updated." $REPORT_FILE
|
||||
cat "$REPORT_FILE"
|
||||
cleanup;;
|
||||
;;
|
||||
|
||||
* )
|
||||
usage
|
||||
;;
|
||||
usage;;
|
||||
esac
|
||||
|
||||
cleanup
|
||||
|
||||
Reference in New Issue
Block a user