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
#
7cd8e9
# Copyright (C) 2009, 2010 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.
905aac
    local ARGSL="update-metadata:,vacuum-defs:,filter:"
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
                # Check action value. Be sure the action value matches
905aac
                # the convenctions defined for source locations inside
905aac
                # the working copy.
905aac
                cli_checkRepoDirSource
905aac
905aac
                # Define action name using action value as reference.
905aac
                ACTIONNAM="${FUNCNAM}_updateMetadata"
905aac
905aac
                # Look for sub-options passed through command-line.
905aac
                while true; do
905aac
905aac
                    case "$3" in
905aac
905aac
                        --filter )
905aac
905aac
                            # Redefine regular expression.
905aac
                            REGEX="$4"
905aac
905aac
                            # Rotate positional parameters.
905aac
                            shift 4
905aac
                            ;;
905aac
905aac
                        * )
905aac
                            # Break sub-options loop.
905aac
                            break
905aac
                            ;;
905aac
                    esac
905aac
                done
905aac
905aac
                # Break options loop.
905aac
                break
905aac
                ;;
905aac
905aac
            --vacuum-defs )
905aac
905aac
                # Define action value.
905aac
                ACTIONVAL="$2"
905aac
905aac
                # Check action value. Be sure the action value matches
905aac
                # the convenctions defined for source locations inside
905aac
                # the working copy.
905aac
                cli_checkRepoDirSource
905aac
905aac
                # Define action name using action value as reference.
905aac
                ACTIONNAM="${FUNCNAM}_vacuumDefs"
905aac
905aac
                # Look for sub-options passed through command-line.
905aac
                while true; do
905aac
905aac
                    case "$3" in
905aac
905aac
                        --filter )
905aac
905aac
                            # Redefine regular expression.
905aac
                            REGEX="$4"
905aac
905aac
                            # Rotate positional parameters.
905aac
                            shift 4
905aac
                            ;;
905aac
905aac
                        * )
905aac
                            # Break sub-options loop.
905aac
                            break
905aac
                            ;;
905aac
                    esac
905aac
                done
905aac
905aac
                # Break options loop.
905aac
                break
905aac
                ;;
905aac
905aac
            * )
905aac
                # Break options loop.
905aac
                break
905aac
        esac
905aac
    done
905aac
905aac
    # Verify action value variable.
905aac
    if [[ $ACTIONVAL == '' ]];then
905aac
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
905aac
    fi
905aac
905aac
    # Re-define regular expression to match scalable vector graphic
905aac
    # files only.
905aac
    REGEX=$(echo "${REGEX}.*\.(svgz|svg)")
905aac
905aac
    # Execute action name.
905aac
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
905aac
        eval $ACTIONNAM
905aac
    else
905aac
        cli_printMessage "`eval_gettext "A valid action is required."`" 'AsErrorLine'
905aac
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
905aac
    fi
641be4
641be4
}