From 66ea8d909cbf2ec044d43f40a2a4abcb6dec38e3 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Dec 27 2010 17:22:26 +0000 Subject: Remove cli_getArguments.sh: - Insie centos-art.sh script command-line argument interpretation of first argument has been divided from interpretation of second arguments on. Interpretation of first argument takes place inside cli.sh function script. Interpretation of second argument on takes place inside specific functionalities independently one from another. Once first argument has been interpreted the positional parameters are rotated to discard the first argument and reset the counting from second (which would turn into the first one) argument on. This is all we do inside cli function definition. Remember that cli function definition takes place before any specific function be loaded, so variable defined here are concidered global for the entire script environment. At this point, interpretation of arguments takes place inside specific functionalities. This is useful to make documentation commands to point the documentation entry related to such functionality. This is also useful to concentrate options definition through getopt in a functionality basis. Each specific functionality is independent one from another. --- diff --git a/Scripts/Bash/Functions/cli_getArguments.sh b/Scripts/Bash/Functions/cli_getArguments.sh deleted file mode 100755 index d969940..0000000 --- a/Scripts/Bash/Functions/cli_getArguments.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/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 "$@" - -}