Run .todo.actions.d Before Builtins

.
Let users override default commands by creating a script in
~/.todo.actions.d/ with the same name as a default command.  Idea by Don
Harper and David A. Harding; patch by Harding.
.
The patch adds the following logic and increases the indent level for
the case statement:
.
+if [ -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ]
+then
+    CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
+else
+    case $action in
This commit is contained in:
David A. Harding
2009-03-07 16:15:15 -05:00
parent fd9b002ce1
commit 20e6892775

15
todo.sh
View File

@@ -332,6 +332,10 @@ shopt -s extglob
# == HANDLE ACTION == # == HANDLE ACTION ==
action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' ) action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' )
if [ -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ]
then
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
else
case $action in case $action in
"add" | "a") "add" | "a")
if [[ -z "$2" && $FORCE = 0 ]]; then if [[ -z "$2" && $FORCE = 0 ]]; then
@@ -744,13 +748,6 @@ note: PRIORITY must be anywhere from A to Z."
* ) * )
usage usage
if [ -d "$HOME/.todo.actions.d" ]; then ;;
if [ -x "$HOME/.todo.actions.d/$action" ]; then
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
else
usage
fi
else
usage
fi
esac esac
fi