From a339316082f86f06b4b8c83c2a73da452e36687a Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Nov 25 2010 18:09:47 +0000 Subject: Update svg functionality: - Rename OPTIONNAM and OPTIONVAL variable names to ACTIONNAM and ACTIONVAL respectively. - Inside svg_vacuumDefs and svg_updateMetadata functions, add positional parameters interpretation using getopt(1), re-define regular expression to match scalable vector graphic files only, and use cli_getFilesList to define list of files to process. --- diff --git a/Scripts/Bash/Functions/Svg/svg.sh b/Scripts/Bash/Functions/Svg/svg.sh index e7925d6..1fb487e 100755 --- a/Scripts/Bash/Functions/Svg/svg.sh +++ b/Scripts/Bash/Functions/Svg/svg.sh @@ -1,7 +1,7 @@ #!/bin/bash # # svg.sh -- This function provides very basic SVG manipulations to -# help maintain svg files inside the repository. +# help you to maintain svg files inside the repository. # # Copyright (C) 2009, 2010 Alain Reguera Delgado # @@ -26,25 +26,10 @@ function svg { + # Define variables. local FILES='' - # Define list of scalable vector graphic files to process using - # option value as reference. - if [[ -d $OPTIONVAL ]];then - FILES=$(find $OPTIONVAL -regextype posix-egrep -type f -regex "^${REGEX}\.svg$") - elif [[ -f $OPTIONVAL ]];then - FILES=$OPTIONVAL - fi - - # Check list of files to process. If list of files is empty there - # is nothing to do except to print a message and end script - # execution. - if [[ $FILES == '' ]];then - cli_printMessage "`gettext "There is no file to process."`" - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi - - # Define command line interface for svg-based actions. + # Define command-line interface. svg_getActions } diff --git a/Scripts/Bash/Functions/Svg/svg_getActions.sh b/Scripts/Bash/Functions/Svg/svg_getActions.sh index ef3fc15..72397da 100755 --- a/Scripts/Bash/Functions/Svg/svg_getActions.sh +++ b/Scripts/Bash/Functions/Svg/svg_getActions.sh @@ -1,7 +1,7 @@ #!/bin/bash # # svg_getActions.sh -- This function initializes SVG string -# manipulation functionalities, using the option value of +# manipulation functionalities, using the action value of # centos-art.sh script as reference. # # Copyright (C) 2009, 2010 Alain Reguera Delgado @@ -27,9 +27,9 @@ function svg_getActions { - # Evaluate option name and define which actions does centos-art.sh + # Evaluate action name and define which actions does centos-art.sh # script supports. - case $OPTIONNAM in + case $ACTIONNAM in '--update-metadata' ) # Update metadata inside svg files using metadata @@ -43,7 +43,7 @@ function svg_getActions { ;; * ) - cli_printMessage "`eval_gettext "The option provided is not valid."`" + cli_printMessage "`gettext "The option provided is not valid."`" 'AsErrorLine' cli_printMessage "$(caller)" 'AsToKnowMoreLine' ;; diff --git a/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh b/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh index 739bb4d..1dfcfc2 100755 --- a/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh +++ b/Scripts/Bash/Functions/Svg/svg_updateMetadata.sh @@ -144,6 +144,39 @@ function svg_updateMetadata { done + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="filter:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + --filter ) + REGEX="$2" + shift 2 + ;; + * ) + break + esac + done + + # Re-define regular expression to match scalable vector graphic + # files only. + REGEX=$(echo "${REGEX}\.(svgz|svg)") + + # Define list of files to process. + cli_getFilesList + + # Process list of files. for FILE in $FILES;do # Output action message. diff --git a/Scripts/Bash/Functions/Svg/svg_vacuumDefs.sh b/Scripts/Bash/Functions/Svg/svg_vacuumDefs.sh index df7d9a4..4669ada 100755 --- a/Scripts/Bash/Functions/Svg/svg_vacuumDefs.sh +++ b/Scripts/Bash/Functions/Svg/svg_vacuumDefs.sh @@ -26,6 +26,39 @@ function svg_vacuumDefs { + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="filter:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + --filter ) + REGEX="$2" + shift 2 + ;; + * ) + break + esac + done + + # Re-define regular expression to match scalable vector graphic + # files only. + REGEX=$(echo "${REGEX}\.(svgz|svg)") + + # Define list of files to process. + cli_getFilesList + + # Process list of files. for FILE in $FILES;do # Output action message.