diff options
-rwxr-xr-x | ltask | 59 |
1 files changed, 26 insertions, 33 deletions
@@ -49,32 +49,6 @@ function perror() { echo -e $@ 1>&2 } -function parse_args() { - for (( i=0; i < $ARGC;i++ )); do - local ARGREGEX="^-.*" - if [[ ! ${ARGV[$i]} =~ $ARGREGEX ]]; then - [ -z $TASK ] && TASK=${ARGV[$i]} && continue - [ -z $TARGET ] && TARGET=${ARGV[$i]} && continue - - print_help 1 - fi - - case ${ARGV[$i]} in - -H) - i=$((i+1)) - HOSTS+=(${ARGV[$i]});; - -p) - PARALLEL="yes";; - -h) - print_help 0;; - *) - echo Invalid Argument ${ARGV[$i]} - echo $0 -h for help - exit 1;; - esac - done -} - selector() { local regex="^-?[0-9]+\$" @@ -107,7 +81,32 @@ EOF exit $1 } -function interactive() { +#Parse args +for (( i=0; i < $ARGC;i++ )); do + ARGREGEX="^-.*" + if [[ ! ${ARGV[$i]} =~ $ARGREGEX ]]; then + [ -z $TASK ] && TASK=${ARGV[$i]} && continue + [ -z $TARGET ] && TARGET=${ARGV[$i]} && continue + + print_help 1 + fi + + case ${ARGV[$i]} in + -H) + i=$((i+1)) + HOSTS+=(${ARGV[$i]});; + -p) + PARALLEL="yes";; + -h) + print_help 0;; + *) + echo Invalid Argument ${ARGV[$i]} + echo $0 -h for help + exit 1;; + esac +done + +if [ -z $TASK ]; then TASK_LIST=( $(ls $TASK_DIR) ) TARGET_LIST=( $(ls $TARGET_DIR) ) @@ -118,12 +117,6 @@ function interactive() { perror "\nSelect a Target" >&2 selector ${TARGET_LIST[@]} TARGET=${TARGET_LIST[$?]} -} - -parse_args - -if [ -z $TASK ]; then - interactive fi unset TASK_ISSET |