From 705eabb228ca0507bba7a591882e2319d6d1e41b Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Dec 28 2010 22:13:24 +0000 Subject: Update `verify' functionality: - Remove command-line arguments interpretation from verify_doEnvironment.sh. - Add command-line arguments interpretation to verify_getActions.sh. - Remove `Define global variables.' comment from verify.sh. --- diff --git a/Scripts/Bash/Functions/Verify/verify.sh b/Scripts/Bash/Functions/Verify/verify.sh index 8a2b5c6..ef6fd65 100755 --- a/Scripts/Bash/Functions/Verify/verify.sh +++ b/Scripts/Bash/Functions/Verify/verify.sh @@ -26,8 +26,6 @@ function verify { - # Define global variables. - # Define command-line interface. verify_getActions diff --git a/Scripts/Bash/Functions/Verify/verify_doEnvironment.sh b/Scripts/Bash/Functions/Verify/verify_doEnvironment.sh index e15ba5e..43d1677 100755 --- a/Scripts/Bash/Functions/Verify/verify_doEnvironment.sh +++ b/Scripts/Bash/Functions/Verify/verify_doEnvironment.sh @@ -45,31 +45,6 @@ function verify_doEnvironment { INFO[3]="`gettext "Default directory used to retrive translated messages"`" INFO[4]="`gettext "Default locale information"`" - # Define short options we want to support. - local ARGSS="" - - # Define long options we want to support. - local ARGSL="filter:" - - # Parse arguments using getopt(1) command parser. - cli_doParseArguments - - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "$ARGUMENTS" - - # Define action to take for each option passed. - while true; do - case "$1" in - --filter ) - REGEX="$2" - shift 2 - ;; - * ) - break - esac - done - until [[ $COUNT -eq ${#VARS[*]} ]];do # Let user to reduce output using regular expression as diff --git a/Scripts/Bash/Functions/Verify/verify_getActions.sh b/Scripts/Bash/Functions/Verify/verify_getActions.sh index e5f8a5c..ea4218e 100755 --- a/Scripts/Bash/Functions/Verify/verify_getActions.sh +++ b/Scripts/Bash/Functions/Verify/verify_getActions.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# verify_getActions.sh -- This function defines the ``verify'' -# command-line interface of centos-art.sh script. +# verify_getActions.sh -- This function interpretes arguments passed +# to `verify' functionality and calls actions accordingly. # # Copyright (C) 2009, 2010 Alain Reguera Delgado # @@ -26,24 +26,126 @@ function verify_getActions { - case $ACTIONNAM in + # Define short options we want to support. + local ARGSS="" - --packages ) - verify_doPackages - ;; + # Define long options we want to support. + local ARGSL="packages,links,environment,filter:" - --links ) - verify_doLinks - ;; + # Parse arguments using getopt(1) command parser. + cli_doParseArguments - --environment ) - verify_doEnvironment - ;; + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" - * ) - cli_printMessage "`gettext "The option provided is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" + # Look for options passed through command-line. + while true; do - esac + case "$1" in + + --packages ) + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_doPackages" + + # Look for sub-options passed through command-line. + while true; do + + case "$2" in + + --filter ) + + # Redefine regular expression. + REGEX="$3" + + # Rotate positional parameters. + shift 3 + ;; + + * ) + # Break sub-options loop. + break + ;; + esac + done + + # Break options loop. + break + ;; + + --links ) + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_doLinks" + + # Look for sub-options passed through command-line. + while true; do + + case "$2" in + + --filter ) + + # Redefine regular expression. + REGEX="$3" + + # Rotate positional parameters. + shift 3 + ;; + + * ) + # Break sub-options loop. + break + ;; + esac + done + + # Break options loop. + break + ;; + + --environment ) + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_doEnvironment" + + # Look for sub-options passed through command-line. + while true; do + + case "$2" in + + --filter ) + + # Redefine regular expression. + REGEX="$3" + + # Rotate positional parameters + shift 3 + ;; + + * ) + # Break sub-options loop. + break + ;; + esac + done + + # Break options loop. + break + ;; + + * ) + # Break options loop. + break + esac + done + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi }