Skip to content

Commit 0e7c091

Browse files
authored
Added status messages for listaddons and file test (#403)
1 parent 8afcc36 commit 0e7c091

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/t8010-listaddons.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ This test checks listing of custom actions.
99

1010
test_todo_session 'no custom actions' <<EOF
1111
>>> todo.sh listaddons
12+
TODO: '$TODO_ACTIONS_DIR' does not exist.
13+
=== 1
1214
EOF
1315

1416
make_action "foo"
1517
test_todo_session 'one custom action' <<EOF
1618
>>> todo.sh listaddons
1719
foo
20+
--
21+
TODO: 1 valid addon actions found.
1822
EOF
1923

2024
make_action "bar"
@@ -26,6 +30,8 @@ bar
2630
foo
2731
ls
2832
quux
33+
--
34+
TODO: 4 valid addon actions found.
2935
EOF
3036

3137
invalidate_action .todo.actions.d/foo t8010.4
@@ -34,6 +40,8 @@ test_todo_session 'nonexecutable action' <<EOF
3440
bar
3541
ls
3642
quux
43+
--
44+
TODO: 3 valid addon actions found.
3745
EOF
3846

3947
make_action_in_folder "chuck"
@@ -59,6 +67,8 @@ chuck
5967
ls
6068
norris
6169
quux
70+
--
71+
TODO: 5 valid addon actions found.
6272
EOF
6373

6474
invalidate_action .todo.actions.d/norris/norris t8010.8
@@ -68,6 +78,8 @@ bar
6878
chuck
6979
ls
7080
quux
81+
--
82+
TODO: 4 valid addon actions found.
7183
EOF
7284

7385
test_done

todo.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ dieWithHelp()
354354

355355
die "$@"
356356
}
357+
357358
die()
358359
{
359360
echo >&2 "$*"
@@ -878,7 +879,7 @@ _list() {
878879
local FILE="$1"
879880
## If the file starts with a "/" use absolute path. Otherwise,
880881
## try to find it in either $TODO_DIR or using a relative path
881-
if [ "${1:0:1}" == / ]; then
882+
if [ "${1:0:1}" == / ] && [ -f "$FILE" ]; then
882883
## Absolute path
883884
src="$FILE"
884885
elif [ -f "$TODO_DIR/$FILE" ]; then
@@ -1523,14 +1524,27 @@ note: PRIORITY must be anywhere from A to Z."
15231524
"listaddons" )
15241525
if [ -d "$TODO_ACTIONS_DIR" ]; then
15251526
cd "$TODO_ACTIONS_DIR" || exit $?
1527+
actionsCnt=0
15261528
for action in *
15271529
do
15281530
if [ -f "$action" ] && [ -x "$action" ]; then
15291531
echo "$action"
1532+
((actionsCnt+=1))
15301533
elif [ -d "$action" ] && [ -x "$action/$action" ]; then
15311534
echo "$action"
1535+
((actionsCnt+=1))
15321536
fi
15331537
done
1538+
if ! [ "$actionsCnt" -gt 0 ]; then
1539+
die "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions."
1540+
else
1541+
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
1542+
echo "--"
1543+
echo "TODO: $actionsCnt valid addon actions found."
1544+
fi
1545+
fi
1546+
else
1547+
die "TODO: '$TODO_ACTIONS_DIR' does not exist."
15341548
fi
15351549
;;
15361550

0 commit comments

Comments
 (0)