Blame Scripts/Bash/Functions/Verify/verify_getActions.sh

3b853a
#!/bin/bash
3b853a
#
705eab
# verify_getActions.sh -- This function interpretes arguments passed
705eab
# to `verify' functionality and calls actions accordingly.
3b853a
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
3b853a
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
3b853a
# 
3b853a
# This program is distributed in the hope that it will be useful, but
3b853a
# WITHOUT ANY WARRANTY; without even the implied warranty of
3b853a
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
3b853a
# General Public License for more details.
3b853a
#
3b853a
# You should have received a copy of the GNU General Public License
3b853a
# along with this program; if not, write to the Free Software
3b853a
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
3b853a
# USA.
3b853a
# 
3b853a
# ----------------------------------------------------------------------
3b853a
# $Id$
3b853a
# ----------------------------------------------------------------------
3b853a
466982
function verify_getActions {
3b853a
705eab
    # Define short options we want to support.
705eab
    local ARGSS=""
3b853a
705eab
    # Define long options we want to support.
705eab
    local ARGSL="packages,links,environment,filter:"
3b853a
705eab
    # Parse arguments using getopt(1) command parser.
705eab
    cli_doParseArguments
3b853a
705eab
    # Reset positional parameters using output from (getopt) argument
705eab
    # parser.
705eab
    eval set -- "$ARGUMENTS"
08abde
705eab
    # Look for options passed through command-line.
705eab
    while true; do
3b853a
705eab
        case "$1" in
705eab
705eab
            --packages )
705eab
705eab
                # Define action name using action value as reference.
705eab
                ACTIONNAM="${FUNCNAM}_doPackages"
705eab
705eab
                # Look for sub-options passed through command-line.
705eab
                while true; do
705eab
705eab
                    case "$2" in
705eab
705eab
                        --filter )
705eab
705eab
                            # Redefine regular expression.
705eab
                            REGEX="$3"
705eab
705eab
                            # Rotate positional parameters.
705eab
                            shift 3
705eab
                            ;;
705eab
705eab
                        * )
705eab
                            # Break sub-options loop.
705eab
                            break
705eab
                            ;;
705eab
                    esac
705eab
                done
705eab
705eab
                # Break options loop.
705eab
                break
705eab
                ;;
705eab
705eab
            --links )
705eab
705eab
                # Define action name using action value as reference.
705eab
                ACTIONNAM="${FUNCNAM}_doLinks"
705eab
705eab
                # Look for sub-options passed through command-line.
705eab
                while true; do
705eab
705eab
                    case "$2" in
705eab
705eab
                        --filter )
705eab
705eab
                            # Redefine regular expression.
705eab
                            REGEX="$3"
705eab
705eab
                            # Rotate positional parameters.
705eab
                            shift 3
705eab
                            ;;
705eab
705eab
                        * )
705eab
                            # Break sub-options loop.
705eab
                            break
705eab
                            ;;
705eab
                    esac
705eab
                done
705eab
705eab
                # Break options loop.
705eab
                break
705eab
                ;;
705eab
705eab
            --environment )
705eab
705eab
                # Define action name using action value as reference.
705eab
                ACTIONNAM="${FUNCNAM}_doEnvironment"
705eab
705eab
                # Look for sub-options passed through command-line.
705eab
                while true; do
705eab
705eab
                    case "$2" in
705eab
705eab
                        --filter )
705eab
705eab
                            # Redefine regular expression.
705eab
                            REGEX="$3"
705eab
705eab
                            # Rotate positional parameters
705eab
                            shift 3
705eab
                            ;;
705eab
705eab
                        * )
705eab
                            # Break sub-options loop.
705eab
                            break
705eab
                            ;;
705eab
                    esac
705eab
                done
705eab
705eab
                # Break options loop.
705eab
                break
705eab
                ;;
705eab
705eab
            * )
705eab
                # Break options loop.
705eab
                break
705eab
        esac
705eab
    done
705eab
705eab
    # Execute action name.
705eab
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
705eab
        eval $ACTIONNAM
705eab
    else
705eab
        cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
705eab
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
705eab
    fi
3b853a
3b853a
}