|
|
c0ee12 |
#!/bin/bash
|
|
|
c0ee12 |
#
|
|
|
1cd3cb |
# shell_getActions.sh -- This function interpretes arguments passed to
|
|
|
1cd3cb |
# `shell' functionality and calls actions accordingly.
|
|
|
c0ee12 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 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.
|
|
|
1cd3cb |
local ARGSL="filter:,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 |
# Check action value. Be sure the action value matches
|
|
|
1cd3cb |
# the convenctions defined for source locations inside
|
|
|
1cd3cb |
# the working copy.
|
|
|
1cd3cb |
cli_checkRepoDirSource
|
|
|
1cd3cb |
|
|
|
1cd3cb |
# Define action name using action value as reference.
|
|
|
1cd3cb |
ACTIONNAM="${FUNCNAM}_updateCopyright"
|
|
|
1cd3cb |
|
|
|
1cd3cb |
# Look for sub-options passed through command-line.
|
|
|
1cd3cb |
while true; do
|
|
|
1cd3cb |
case "$3" in
|
|
|
1cd3cb |
--filter )
|
|
|
1cd3cb |
# Redefine regular expression.
|
|
|
1cd3cb |
REGEX="$4"
|
|
|
1cd3cb |
# Rotate positional parameters
|
|
|
1cd3cb |
shift 4
|
|
|
1cd3cb |
;;
|
|
|
1cd3cb |
* )
|
|
|
1cd3cb |
# Break sub-options loop.
|
|
|
1cd3cb |
break
|
|
|
1cd3cb |
;;
|
|
|
1cd3cb |
esac
|
|
|
1cd3cb |
done
|
|
|
1cd3cb |
|
|
|
1cd3cb |
# Break options loop.
|
|
|
1cd3cb |
break
|
|
|
1cd3cb |
;;
|
|
|
1cd3cb |
|
|
|
1cd3cb |
* )
|
|
|
1cd3cb |
# Break options loop.
|
|
|
1cd3cb |
break
|
|
|
1cd3cb |
esac
|
|
|
1cd3cb |
done
|
|
|
1cd3cb |
|
|
|
1cd3cb |
# Verify action value variable.
|
|
|
1cd3cb |
if [[ $ACTIONVAL == '' ]];then
|
|
|
1cd3cb |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
1cd3cb |
fi
|
|
|
1cd3cb |
|
|
|
1cd3cb |
# Execute action name.
|
|
|
1cd3cb |
if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
|
|
|
1cd3cb |
eval $ACTIONNAM
|
|
|
1cd3cb |
else
|
|
|
1cd3cb |
cli_printMessage "`eval_gettext "A valid action is required."`" 'AsErrorLine'
|
|
|
1cd3cb |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
1cd3cb |
fi
|
|
|
4fac24 |
|
|
|
c0ee12 |
}
|