diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2010-11-21 17:19:01 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2010-11-21 17:19:01 -0200 |
commit | 7702aae3a471b4321833527931b71ce6b48b511b (patch) | |
tree | 36f11f0d232ccb62ba92f594769ece23e51f0b8c /lib/hydra/action | |
parent | 627dcf039b289858b3d36958f526b857e04d048e (diff) | |
download | hydra-7702aae3a471b4321833527931b71ce6b48b511b.tar.gz hydra-7702aae3a471b4321833527931b71ce6b48b511b.tar.bz2 |
Splitting lib functions in smaller files
Diffstat (limited to 'lib/hydra/action')
-rw-r--r-- | lib/hydra/action | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/hydra/action b/lib/hydra/action new file mode 100644 index 0000000..b5d76a9 --- /dev/null +++ b/lib/hydra/action @@ -0,0 +1,43 @@ +#!/bin/bash + +# Check if there is a given action +function hydra_has_action { + if [ -z "$ACTIONS" ]; then + echo "Your have to set ACTIONS variable in the code" + exit 1 + fi + + if [ -e "$ACTIONS/$1" ]; then + true + else + false + fi +} + +# Execute an action +function hydra_exec { + # Setup + action="$1" + shift 2 + + # Dispatch + if hydra_has_action $action; then + $ACTIONS/$action $* + fi +} + +# Get a command argument +function hydra_get_command { + # Aditional parameters + COMMAND="$1" + + if [ -z "$COMMAND" ]; then + hydra_action_usage command + exit 1 + fi +} + +# Action dispatcher +function hydra_dispatch { + hydra_exec $ACTION $* +} |