Blame Scripts/Bash/Functions/Svg/svg_getActions.sh

641be4
#!/bin/bash
641be4
#
905aac
# svg_getActions.sh -- This function interpretes arguments passed to
905aac
# `svg' functionality and calls actions accordingly.
641be4
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
641be4
# 
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.
641be4
# 
641be4
# This program is distributed in the hope that it will be useful, but
641be4
# WITHOUT ANY WARRANTY; without even the implied warranty of
641be4
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
641be4
# General Public License for more details.
641be4
#
641be4
# You should have received a copy of the GNU General Public License
641be4
# along with this program; if not, write to the Free Software
641be4
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
641be4
# USA.
641be4
# 
641be4
# ----------------------------------------------------------------------
641be4
# $Id$
641be4
# ----------------------------------------------------------------------
641be4
    
641be4
function svg_getActions {
641be4
905aac
    # Define short options we want to support.
905aac
    local ARGSS=""
641be4
905aac
    # Define long options we want to support.
03a4b4
    local ARGSL="update-metadata:,vacuum-defs:"
641be4
905aac
    # Parse arguments using getopt(1) command parser.
905aac
    cli_doParseArguments
ae2c20
905aac
    # Reset positional parameters using output from (getopt) argument
905aac
    # parser.
905aac
    eval set -- "$ARGUMENTS"
905aac
905aac
    # Look for options passed through command-line.
905aac
    while true; do
905aac
905aac
        case "$1" in
905aac
905aac
            --update-metadata )
905aac
905aac
                # Define action value.
905aac
                ACTIONVAL="$2"
905aac
905aac
                # Define action name using action value as reference.
905aac
                ACTIONNAM="${FUNCNAM}_updateMetadata"
905aac
03a4b4
                # Rotate positional parameters.
03a4b4
                shift 2
905aac
                ;;
905aac
905aac
            --vacuum-defs )
905aac
905aac
                # Define action value.
905aac
                ACTIONVAL="$2"
905aac
905aac
                # Define action name using action value as reference.
905aac
                ACTIONNAM="${FUNCNAM}_vacuumDefs"
905aac
03a4b4
                # Rotate positional parameters.
03a4b4
                shift 2
905aac
                ;;
905aac
905aac
            * )
905aac
                # Break options loop.
905aac
                break
905aac
        esac
905aac
    done
905aac
03a4b4
    # Check action value. Be sure the action value matches the
03a4b4
    # convenctions defined for source locations inside the working
03a4b4
    # copy.
03a4b4
    cli_checkRepoDirSource
905aac
03a4b4
    # Syncronize changes between the working copy and the central
03a4b4
    # repository to bring down changes.
03a4b4
    cli_commitRepoChanges
905aac
905aac
    # Execute action name.
905aac
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
905aac
        eval $ACTIONNAM
905aac
    else
03a4b4
        cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
905aac
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
905aac
    fi
641be4
03a4b4
    # Syncronize changes between the working copy and the central
03a4b4
    # repository to commit up changes.
03a4b4
    cli_commitRepoChanges
03a4b4
641be4
}