Allow for placing addons in subfolders.

Addons can be placed in subfolders with the same name as the action,
in order to be able to e.g. clone git repos into the TODO_ACTIONS_DIR
rather than having to download addons and manage updates manually.

Closes #120
This commit is contained in:
nthorne
2013-11-22 23:20:55 +01:00
committed by Gina Trapani
parent 07b50a07e0
commit 7c92f46c25
4 changed files with 96 additions and 4 deletions

16
todo.sh
View File

@@ -302,6 +302,14 @@ addonHelp()
didPrintAddonActionsHeader=1
fi
"$action" usage
elif [ -d "$action" -a -x "$action/$(basename $action)" ]; then
if [ ! "$didPrintAddonActionsHeader" ]; then
cat <<-EndAddonActionsHeader
Add-on Actions:
EndAddonActionsHeader
didPrintAddonActionsHeader=1
fi
"$action/$(basename $action)" usage
fi
done
fi
@@ -314,6 +322,8 @@ actionUsage()
action="${TODO_ACTIONS_DIR}/${actionName}"
if [ -f "$action" -a -x "$action" ]; then
"$action" usage
elif [ -d "$action" -a -x "$action/$(basename $action)" ]; then
"$action/$(basename $action)" usage
else
builtinActionUsage=$(actionsHelp | sed -n -e "/^ ${actionName//\//\\/} /,/^\$/p" -e "/^ ${actionName//\//\\/}$/,/^\$/p")
if [ "$builtinActionUsage" ]; then
@@ -964,6 +974,10 @@ then
shift
## Reset action to new first argument
action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' )
elif [ -d "$TODO_ACTIONS_DIR/$action" -a -x "$TODO_ACTIONS_DIR/$action/$action" ]
then
"$TODO_ACTIONS_DIR/$action/$action" "$@"
exit $?
elif [ -d "$TODO_ACTIONS_DIR" -a -x "$TODO_ACTIONS_DIR/$action" ]
then
"$TODO_ACTIONS_DIR/$action" "$@"
@@ -1405,6 +1419,8 @@ note: PRIORITY must be anywhere from A to Z."
do
if [ -f "$action" -a -x "$action" ]; then
echo "$action"
elif [ -d "$action" -a -x "$action/$action" ]; then
echo "$action"
fi
done
fi