Blame Scripts/Bash/Functions/Shell/shell_getActions.sh

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