Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added status messages for listaddons and file test #403

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/t8010-listaddons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ This test checks listing of custom actions.

test_todo_session 'no custom actions' <<EOF
>>> todo.sh listaddons
TODO: '$TODO_ACTIONS_DIR' does not exist.
=== 1
EOF

make_action "foo"
test_todo_session 'one custom action' <<EOF
>>> todo.sh listaddons
foo
--
TODO: 1 valid addon actions found.
EOF

make_action "bar"
Expand All @@ -26,6 +30,8 @@ bar
foo
ls
quux
--
TODO: 4 valid addon actions found.
EOF

chmod -x .todo.actions.d/foo
Expand All @@ -39,6 +45,8 @@ test_todo_session 'nonexecutable action' <<EOF
bar
ls
quux
--
TODO: 3 valid addon actions found.
EOF

make_action_in_folder "chuck"
Expand All @@ -64,6 +72,8 @@ chuck
ls
norris
quux
--
TODO: 5 valid addon actions found.
EOF

# nthorne: shamelessly stolen from above..
Expand All @@ -79,6 +89,8 @@ bar
chuck
ls
quux
--
TODO: 4 valid addon actions found.
EOF

test_done
18 changes: 16 additions & 2 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,10 @@ dieWithHelp()

die "$@"
}

die()
{
echo "$*"
echo >&2 "$*"
exit 1
}

Expand Down Expand Up @@ -864,7 +865,7 @@ _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}" == / ] && [ -f "$FILE" ]; then
## Absolute path
src="$FILE"
elif [ -f "$TODO_DIR/$FILE" ]; then
Expand Down Expand Up @@ -1485,14 +1486,27 @@ note: PRIORITY must be anywhere from A to Z."
"listaddons" )
if [ -d "$TODO_ACTIONS_DIR" ]; then
cd "$TODO_ACTIONS_DIR" || exit $?
actionsCnt=0
for action in *
do
if [ -f "$action" ] && [ -x "$action" ]; then
echo "$action"
((actionsCnt+=1))
elif [ -d "$action" ] && [ -x "$action/$action" ]; then
echo "$action"
((actionsCnt+=1))
fi
done
if ! [ "$actionsCnt" -gt 0 ]; then
die "TODO: '$TODO_ACTIONS_DIR' does not contain valid actions."
else
if [ "$TODOTXT_VERBOSE" -gt 0 ]; then
echo "--"
echo "TODO: $actionsCnt valid addon actions found."
fi
fi
else
die "TODO: '$TODO_ACTIONS_DIR' does not exist."
fi
;;

Expand Down