|
|
b7b189 |
#!/bin/bash
|
|
|
b7b189 |
#
|
|
|
b7b189 |
# cli_getActionArguments.sh -- This function initializes the action
|
|
|
b7b189 |
# name and value used by functionalities to perform their goals.
|
|
|
b7b189 |
#
|
|
|
b7b189 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
b7b189 |
#
|
|
|
b7b189 |
# This program is free software; you can redistribute it and/or modify
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
#
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
# General Public License for more details.
|
|
|
b7b189 |
#
|
|
|
b7b189 |
|
|
|
b7b189 |
# along with this program; if not, write to the Free Software
|
|
|
b7b189 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
b7b189 |
# USA.
|
|
|
b7b189 |
#
|
|
|
b7b189 |
# ----------------------------------------------------------------------
|
|
|
b7b189 |
# $Id$
|
|
|
b7b189 |
# ----------------------------------------------------------------------
|
|
|
b7b189 |
|
|
|
b7b189 |
function cli_getActionArguments {
|
|
|
b7b189 |
|
|
|
b7b189 |
# Set command-line arguments for processing using positional
|
|
|
b7b189 |
|
|
|
b7b189 |
eval set -- "$ARGUMENTS"
|
|
|
b7b189 |
|
|
|
b7b189 |
# Define function name (FUNCNAM) variable from first command-line
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
FUNCNAM=$(cli_getRepoName "$1" 'f')
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
if [[ "$2" =~ '^--[a-z-]+=.+$' ]];then
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
ACTIONNAM=$(echo "$2" | cut -d = -f1)
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
ACTIONVAL=$(echo "$2" | cut -d = -f2-)
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
elif [[ "$2" =~ '^--[a-z-]+=?$' ]];then
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
ACTIONNAM=$(echo "$2" | cut -d = -f1)
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
# no action value (ACTIONVAL) entered from command-line here.
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
if [[ $(pwd) =~ '^/home/centos/artwork' ]];then
|
|
|
b7b189 |
ACTIONVAL=$(pwd)
|
|
|
b7b189 |
fi
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
# or not specified at all.
|
|
|
b7b189 |
else
|
|
|
b7b189 |
cli_printMessage "`gettext "Missing arguments."`" 'AsErrorLine'
|
|
|
b7b189 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
b7b189 |
fi
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
cli_checkActionArguments
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
# we remove it from command-line arguments in order for getopt to
|
|
|
b7b189 |
|
|
|
b7b189 |
# $1, what was previously set on $3 is now set at $2, and so on.
|
|
|
b7b189 |
shift 2
|
|
|
b7b189 |
|
|
|
b7b189 |
|
|
|
b7b189 |
cli_doParseArgumentsReDef "$@"
|
|
|
b7b189 |
|
|
|
b7b189 |
}
|