Blame Scripts/Bash/Functions/Locale/locale_getActions.sh

4c79b5
#!/bin/bash
4c79b5
#
6c8ab9
# locale_getActions.sh -- This function interprets arguments passed to
6c8ab9
# `locale' functionality and calls actions accordingly.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
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.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function locale_getActions {
4c79b5
6c8ab9
    # Define short options we want to support.
6c8ab9
    local ARGSS="f:"
4c79b5
6c8ab9
    # Define long options we want to support.
6c8ab9
    local ARGSL="filter:,status,edit"
4c79b5
6c8ab9
    # Parse arguments using getopt(1) command parser.
6c8ab9
    cli_doParseArguments
4c79b5
6c8ab9
    # Reset positional parameters using output from (getopt) argument
6c8ab9
    # parser.
6c8ab9
    eval set -- "$ARGUMENTS"
4c79b5
6c8ab9
    # Define action to take for each option passed.
6c8ab9
    while true; do
6c8ab9
        case "$1" in
6c8ab9
6c8ab9
            --status )
6c8ab9
6c8ab9
                # Redefine action name.
6c8ab9
                ACTIONNAM="${FUNCNAM}_doMessagesStatus"
6c8ab9
6c8ab9
                # Redefine action value. There is no action value to
6c8ab9
                # verify here.
6c8ab9
6c8ab9
                # Break while loop.
2666db
                shift 1
6c8ab9
                ;;
6c8ab9
6c8ab9
            --edit )
6c8ab9
6c8ab9
                # Redefine action name.
6c8ab9
                ACTIONNAM="${FUNCNAM}_doMessages"
6c8ab9
6c8ab9
                # Redefine action value. It is required for
6c8ab9
                # cli_commitRepoChanges to know where locale changes
6c8ab9
                # are.
6c8ab9
                ACTIONVAL=/home/centos/artwork/trunk/Scripts/Bash/Locale
6c8ab9
6c8ab9
                # Verify action value variable.
6c8ab9
                if [[ $ACTIONVAL == '' ]];then
6c8ab9
                    cli_printMessage "$(caller)" 'AsToKnowMoreLine'
6c8ab9
                fi
6c8ab9
6c8ab9
                # Break while loop.
2666db
                shift 1
6c8ab9
                ;;
6c8ab9
bd587b
            --filter )
bd587b
bd587b
                # Redefine filter (regular expression) flag.
bd587b
                FLAG_FILTER="$2"
bd587b
                
bd587b
                # Rotate positional parameters
bd587b
                shift 2
bd587b
                ;;
bd587b
6c8ab9
            * )
6c8ab9
                break
6c8ab9
        esac
6c8ab9
    done
6c8ab9
6c8ab9
    # Execute action name.
6c8ab9
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
6c8ab9
        eval $ACTIONNAM
6c8ab9
    else
6c8ab9
        cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
6c8ab9
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
6c8ab9
    fi
4c79b5
4c79b5
}