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.
786ebb
    local ARGSS=""
4c79b5
6c8ab9
    # Define long options we want to support.
4e4b4d
    local ARGSL="update:,edit:,report:"
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
786ebb
            --update )
6c8ab9
6c8ab9
                # Redefine action name.
4e4b4d
                ACTIONNAM="${FUNCNAM}_updateMessages"
6c8ab9
786ebb
                # Redefine action value.
786ebb
                ACTIONVAL="$2"
6c8ab9
6c8ab9
                # Break while loop.
786ebb
                shift 2
6c8ab9
                ;;
6c8ab9
6c8ab9
            --edit )
6c8ab9
6c8ab9
                # Redefine action name.
4e4b4d
                ACTIONNAM="${FUNCNAM}_editMessages"
786ebb
786ebb
                # Redefine action value.
786ebb
                ACTIONVAL="$2"
786ebb
786ebb
                # Break while loop.
786ebb
                shift 2
786ebb
                ;;
786ebb
4e4b4d
            --report )
6c8ab9
786ebb
                # Redefine action name.
4e4b4d
                ACTIONNAM="${FUNCNAM}_printTranslationReport"
6c8ab9
786ebb
                # Redefine action value.
786ebb
                ACTIONVAL="$2"
6c8ab9
6c8ab9
                # Break while loop.
786ebb
                shift 2
6c8ab9
                ;;
6c8ab9
6c8ab9
            * )
6c8ab9
                break
4e4b4d
                ;;
6c8ab9
        esac
6c8ab9
    done
6c8ab9
786ebb
    # Check action value. Be sure the action value matches the
786ebb
    # convenctions defined for source locations inside the working
786ebb
    # copy.
786ebb
    cli_checkRepoDirSource
786ebb
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
}