From 1cd3cb3ac598f1626b6b445ae98ee79715d66e1b Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Dec 28 2010 21:46:14 +0000 Subject: Update `shell' functionality: - Update command-line arguments interpretation inside shell_getActions. - Update tpl_forCopyright.sed. Use range to separate years and two spaces between years and author name. --- diff --git a/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed b/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed index aed8b87..982db9c 100644 --- a/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed +++ b/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed @@ -6,7 +6,7 @@ # $Id$ # --------------------------------------------------- /^# +Copyright .*$/a\ -# Copyright (C) =YEAR1=, =YEAR2= =FULLNAME=\ +# Copyright (C) =YEAR1=-=YEAR2= =FULLNAME=\ # \ # This program is free software; you can redistribute it and/or\ # modify it under the terms of the GNU General Public License as\ diff --git a/Scripts/Bash/Functions/Shell/shell_getActions.sh b/Scripts/Bash/Functions/Shell/shell_getActions.sh index 0fb833b..cd63d9f 100755 --- a/Scripts/Bash/Functions/Shell/shell_getActions.sh +++ b/Scripts/Bash/Functions/Shell/shell_getActions.sh @@ -1,8 +1,7 @@ #!/bin/bash # -# shell_getActions.sh -- This function initializes very simple string -# manipulations to Bash scripts (*.sh), using the action value of -# centos-art.sh script as reference. +# shell_getActions.sh -- This function interpretes arguments passed to +# `shell' functionality and calls actions accordingly. # # Copyright (C) 2009, 2010 Alain Reguera Delgado # @@ -27,20 +26,74 @@ function shell_getActions { - # Evaluate action name and define which actions does centos-art.sh - # script supports. - case $ACTIONNAM in + # Define short options we want to support. + local ARGSS="" - '--update-copyright' ) - # Update copyright note inside top comments. - shell_updateCopyright - ;; + # Define long options we want to support. + local ARGSL="filter:,update-copyright:" - * ) - cli_printMessage "`gettext "The option provided is not valid."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - ;; + # Parse arguments using getopt(1) command parser. + cli_doParseArguments - esac + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Look for options passed through command-line. + while true; do + + case "$1" in + + --update-copyright ) + + # Define action value. + ACTIONVAL="$2" + + # Check action value. Be sure the action value matches + # the convenctions defined for source locations inside + # the working copy. + cli_checkRepoDirSource + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_updateCopyright" + + # Look for sub-options passed through command-line. + while true; do + case "$3" in + --filter ) + # Redefine regular expression. + REGEX="$4" + # Rotate positional parameters + shift 4 + ;; + * ) + # Break sub-options loop. + break + ;; + esac + done + + # Break options loop. + break + ;; + + * ) + # Break options loop. + break + esac + done + + # Verify action value variable. + if [[ $ACTIONVAL == '' ]];then + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`eval_gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi }