From 817c4d9232e1038047254d8ac135507536bb6ee7 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Dec 07 2010 15:10:09 +0000 Subject: Rename cli_getActionArguments to cli_getArguments. --- diff --git a/Scripts/Bash/Functions/cli.sh b/Scripts/Bash/Functions/cli.sh index b54c89d..668a0ba 100644 --- a/Scripts/Bash/Functions/cli.sh +++ b/Scripts/Bash/Functions/cli.sh @@ -42,7 +42,7 @@ function cli { # ACTIONVAL). As convenction we use the first command-line # argument position to define FUNCNAM, and second argument # position to define both ACTIONNAM and ACTIONVAL. - cli_getActionArguments + cli_getArguments # Define default text editors used by centos-art.sh script. if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then diff --git a/Scripts/Bash/Functions/cli_getActionArguments.sh b/Scripts/Bash/Functions/cli_getActionArguments.sh deleted file mode 100755 index 9a55b1b..0000000 --- a/Scripts/Bash/Functions/cli_getActionArguments.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# -# cli_getActionArguments.sh -- This function initializes the action -# name and value used by functionalities to perform their goals. -# -# Copyright (C) 2009, 2010 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_getActionArguments { - - # Set command-line arguments for processing using positional - # parameters variables. - eval set -- "$ARGUMENTS" - - # Define function name (FUNCNAM) variable from first command-line - # argument. As convenction we use the first argument to determine - # the exact name of functionality to call. Later we use action - # name (ACTIONNAM) and action value (ACTIONVAL) to know, inside - # functionality defined by FUNCNAME, the exact action to perform. - FUNCNAM=$(cli_getRepoName "$1" 'f') - - # Define action name (ACTIONNAM) and action value (ACTIONVAL) - # variables passed as second argument to the command line - # interface when the format is `--option=value' without the value - # # part. - if [[ "$2" =~ '^--[a-z-]+=.+$' ]];then - - # Define action name passed in the second argument. - ACTIONNAM=$(echo "$2" | cut -d = -f1) - - # Define action value passed in the second argument. - ACTIONVAL=$(echo "$2" | cut -d = -f2-) - - # Define action name (ACTIONNAM), and action value (ACTIONVAL) - # variables passed as second argument to the command line - # interface when the format is `--option' without the value part. - elif [[ "$2" =~ '^--[a-z-]+=?$' ]];then - - # Define action name passed in the second argument. - ACTIONNAM=$(echo "$2" | cut -d = -f1) - - # Define action value passed in the second argument. There is - # no action value (ACTIONVAL) entered from command-line here. - # To find out which action value to use, check current working - # directory, and if inside the repository, use current working - # directory as ACTIONVAL default value. - if [[ $(pwd) =~ '^/home/centos/artwork' ]];then - ACTIONVAL=$(pwd) - fi - - # Define default action when second argument is wrongly specified, - # or not specified at all. - else - cli_printMessage "`gettext "Missing arguments."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Check action value passed in the second argument. - cli_checkActionArguments - - # Remove the first and second arguments passed to centos-art.sh - # command-line in order to build optional arguments, they are - # already set in FUNCNAM, ACTIONNAM, and ACTIONVAL variables, so - # we remove it from command-line arguments in order for getopt to - # interpret it not. Now, what was preivously set on $2 is now at - # $1, what was previously set on $3 is now set at $2, and so on. - shift 2 - - # Redefine positional parameters stored inside ARGUMENTS variable. - cli_doParseArgumentsReDef "$@" - -} diff --git a/Scripts/Bash/Functions/cli_getArguments.sh b/Scripts/Bash/Functions/cli_getArguments.sh new file mode 100755 index 0000000..d969940 --- /dev/null +++ b/Scripts/Bash/Functions/cli_getArguments.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# +# cli_getArguments.sh -- This function initializes the action +# name and value used by functionalities to perform their goals. +# +# Copyright (C) 2009, 2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_getArguments { + + # Set command-line arguments for processing using positional + # parameters variables. + eval set -- "$ARGUMENTS" + + # Define function name (FUNCNAM) variable from first command-line + # argument. As convenction we use the first argument to determine + # the exact name of functionality to call. Later we use action + # name (ACTIONNAM) and action value (ACTIONVAL) to know, inside + # functionality defined by FUNCNAME, the exact action to perform. + FUNCNAM=$(cli_getRepoName "$1" 'f') + + # Define action name (ACTIONNAM) and action value (ACTIONVAL) + # variables passed as second argument to the command line + # interface when the format is `--option=value' without the value + # # part. + if [[ "$2" =~ '^--[a-z-]+=.+$' ]];then + + # Define action name passed in the second argument. + ACTIONNAM=$(echo "$2" | cut -d = -f1) + + # Define action value passed in the second argument. + ACTIONVAL=$(echo "$2" | cut -d = -f2-) + + # Define action name (ACTIONNAM), and action value (ACTIONVAL) + # variables passed as second argument to the command line + # interface when the format is `--option' without the value part. + elif [[ "$2" =~ '^--[a-z-]+=?$' ]];then + + # Define action name passed in the second argument. + ACTIONNAM=$(echo "$2" | cut -d = -f1) + + # Define action value passed in the second argument. There is + # no action value (ACTIONVAL) entered from command-line here. + # To find out which action value to use, check current working + # directory, and if inside the repository, use current working + # directory as ACTIONVAL default value. + if [[ $(pwd) =~ '^/home/centos/artwork' ]];then + ACTIONVAL=$(pwd) + fi + + # Define default action when second argument is wrongly specified, + # or not specified at all. + else + cli_printMessage "`gettext "Missing arguments."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Check action value passed in the second argument. + cli_checkActionArguments + + # Remove the first and second arguments passed to centos-art.sh + # command-line in order to build optional arguments, they are + # already set in FUNCNAM, ACTIONNAM, and ACTIONVAL variables, so + # we remove it from command-line arguments in order for getopt to + # interpret it not. Now, what was preivously set on $2 is now at + # $1, what was previously set on $3 is now set at $2, and so on. + shift 2 + + # Redefine positional parameters stored inside ARGUMENTS variable. + cli_doParseArgumentsReDef "$@" + +}