Blame Scripts/Bash/Functions/Render/render_getActions.sh

4c79b5
#!/bin/bash
4c79b5
#
07c2fe
# render_getActions.sh -- This function interprets arguments passed to
07c2fe
# render functionality and calls actions accordingly.
4c79b5
#
7cd8e9
# Copyright (C) 2009, 2010 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 render_getActions {
4c79b5
07c2fe
    # Define short options we want to support.
07c2fe
    local ARGSS="d:f:"
4c79b5
07c2fe
    # Define long options we want to support.
07c2fe
    local ARGSL="directory:,filter:"
4c79b5
07c2fe
    # Parse arguments using getopt(1) command parser.
07c2fe
    cli_doParseArguments
4c79b5
07c2fe
    # Reset positional parameters using output from (getopt) argument
07c2fe
    # parser.
07c2fe
    eval set -- "$ARGUMENTS"
4c79b5
07c2fe
    # Look for options passed through command-line.
07c2fe
    while true; do
4c79b5
07c2fe
        case "$1" in
4c79b5
07c2fe
            -d|--directory )
4c79b5
07c2fe
                # Define action value.
07c2fe
                ACTIONVAL="$2"
4c79b5
07c2fe
                # Check action value. Be sure the action value matches
07c2fe
                # the convenctions defined for source locations inside
07c2fe
                # the working copy.
07c2fe
                cli_checkRepoDirSource
4c79b5
07c2fe
                # Define action name using action value as reference.
07c2fe
                if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Identity/.+$" ]];then
07c2fe
                    ACTIONNAM="${FUNCNAM}_getActionsIdentity"
07c2fe
                elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Translations/.+$" ]];then
07c2fe
                    ACTIONNAM="${FUNCNAM}_getActionsTranslations"
07c2fe
                else
07c2fe
                    cli_printMessage "`eval_gettext "Cannot process the path \\\`\\\$ACTIONVAL'."`" 'AsErrorLine'
07c2fe
                    cli_printMessage "$(caller)" 'AsToKnowMoreLine'
07c2fe
                fi
4c79b5
07c2fe
                # Look for sub-options passed through command-line.
07c2fe
                while true; do
07c2fe
                    case "$3" in
07c2fe
                        -f|--filter )
07c2fe
                            # Redefine regular expression.
07c2fe
                            REGEX="$4"
07c2fe
                            # Rotate positional parameters
07c2fe
                            shift 4
07c2fe
                            ;;
07c2fe
                        * )
07c2fe
                            # Break sub-options loop.
07c2fe
                            break
07c2fe
                            ;;
07c2fe
                    esac
07c2fe
                done
4c79b5
07c2fe
                # Break options loop.
07c2fe
                break
07c2fe
                ;;
4c79b5
07c2fe
            * )
07c2fe
                # Break options loop.
07c2fe
                break
07c2fe
        esac
07c2fe
    done
07c2fe
07c2fe
    # Verify action value variable.
07c2fe
    if [[ $ACTIONVAL == '' ]];then
07c2fe
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
07c2fe
    fi
07c2fe
07c2fe
    # Redefine pre-rendering configuration directory. Pre-rendering
07c2fe
    # configuration directory is where we store render.conf.sh
07c2fe
    # scripts. The render.conf.sh scripts define how each artwork is
07c2fe
    # rendered.
07c2fe
    local ARTCONF=$(echo "$ACTIONVAL" \
07c2fe
        | sed -r -e 's!/(Identity|Translations)!/Scripts/Bash/Functions/Render/Config/\1!' \
07c2fe
                 -e "s!Motifs/$(cli_getThemeName)/?!!")
07c2fe
07c2fe
    # Execute action name.
07c2fe
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
07c2fe
        eval $ACTIONNAM
07c2fe
    else
07c2fe
        cli_printMessage "`eval_gettext "A valid action is required."`" 'AsErrorLine'
07c2fe
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
07c2fe
    fi
4c79b5
4c79b5
}