Blame Scripts/Bash/Functions/Identity/identity_getActions.sh

4c79b5
#!/bin/bash
4c79b5
#
e912f5
# identity_getActions.sh -- This function interprets arguments passed to
07c2fe
# render 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
e912f5
function identity_getActions {
4c79b5
07c2fe
    # Define short options we want to support.
15b1d2
    local ARGSS=""
4c79b5
07c2fe
    # Define long options we want to support.
a615b0
    local ARGSL="render:,release:,architecture:,copy:,to:"
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
a615b0
            --render )
4c79b5
15b1d2
                # Redefine action name.
7fde83
                ACTIONNAM="${FUNCNAM}_render"
4c79b5
a615b0
                # Redefine action value.
a615b0
                ACTIONVAL="$2"
15b1d2
15b1d2
                # Rotate positional parameters
15b1d2
                shift 2
15b1d2
                ;;
15b1d2
15b1d2
            --copy )
15b1d2
            
15b1d2
                # Redefine action value variable.
15b1d2
                ACTIONVAL="$2"
15b1d2
15b1d2
                # Redefine action name variable.
15b1d2
                ACTIONNAM="${FUNCNAME}_doCopy"
15b1d2
15b1d2
                # Rotate positional parameters
15b1d2
                shift 2
15b1d2
                ;;
15b1d2
a615b0
            --release )
15b1d2
            
a615b0
                # Redefine release number flag.
a615b0
                FLAG_RELEASE="$2"
a615b0
a615b0
                # Verify release number flag.
a615b0
                if [[ ! $FLAG_RELEASE =~ $(cli_getPathComponent '--release-pattern') ]];then
a615b0
                    cli_printMessage "`gettext "The release number provided is not supported."`" 'AsErrorLine'
a615b0
                    cli_printMessage "$(caller)" 'AsToKnowMoreLine'
a615b0
                fi
15b1d2
15b1d2
                # Rotate positional parameters
15b1d2
                shift 2
15b1d2
                ;;
15b1d2
a615b0
            --architecture )
a615b0
            
a615b0
                # Redefine architecture flag.
a615b0
                FLAG_ARCHITECTURE="$2"
15b1d2
a615b0
                # Verify architecture flag.
a615b0
                if [[ ! $FLAG_ARCHITECTURE =~ $(cli_getPathComponent '--architecture-pattern') ]];then
a615b0
                    cli_printMessage "`gettext "The architecture provided is not supported."`" 'AsErrorLine'
a615b0
                    cli_printMessage "$(caller)" 'AsToKnowMoreLine'
a615b0
                fi
15b1d2
15b1d2
                # Rotate positional parameters
a615b0
                shift 2
15b1d2
                ;;
15b1d2
a615b0
            --to )
a615b0
            
a615b0
                # Redefine target value flag.
a615b0
                FLAG_TO="$2"
15b1d2
15b1d2
                # Rotate positional parameters
a615b0
                shift 2
07c2fe
                ;;
4c79b5
07c2fe
            * )
07c2fe
                # Break options loop.
07c2fe
                break
07c2fe
        esac
07c2fe
    done
07c2fe
15b1d2
    # Check action value. Be sure the action value matches the
15b1d2
    # convenctions defined for source locations inside the working
15b1d2
    # copy.
15b1d2
    cli_checkRepoDirSource
07c2fe
a615b0
    # Define pre-rendition configuration directory. Pre-rendition
07c2fe
    # configuration directory is where we store render.conf.sh
a615b0
    # scripts. The render.conf.sh script defines how each identity
a615b0
    # content is rendered.
07c2fe
    local ARTCONF=$(echo "$ACTIONVAL" \
fa8704
        | sed -r -e 's!/(Identity)!/Scripts/Bash/Functions/Identity/Config/\1!' \
e0066e
                 -e "s!Motifs/$(cli_getPathComponent '--theme')/?!!")
07c2fe
a615b0
    # Check directory of pre-rendition configuration script.
a615b0
    cli_checkFiles "$ARTCONF" 'd'
a615b0
a615b0
    # Syncronize changes between the working copy and the central
a615b0
    # repository to bring down changes.
a615b0
    cli_commitRepoChanges
a615b0
07c2fe
    # Execute action name.
07c2fe
    if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
07c2fe
        eval $ACTIONNAM
07c2fe
    else
a615b0
        cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
07c2fe
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
07c2fe
    fi
4c79b5
a615b0
    # Syncronize changes between the working copy and the central
a615b0
    # repository to commit up changes.
a615b0
    cli_commitRepoChanges
a615b0
4c79b5
}