From 1f1b3ce4ae06079261f47413af98996ae02cd752 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 23 2010 13:53:20 +0000 Subject: Start using caller builtin to produce documentation entries when using cli_printMessage's AsToKnowMoreLine option. --- diff --git a/Scripts/Bash/Functions/Help/help_addNewFilesToWorkingCopy.sh b/Scripts/Bash/Functions/Help/help_addNewFilesToWorkingCopy.sh index 7a56e2d..400cb17 100644 --- a/Scripts/Bash/Functions/Help/help_addNewFilesToWorkingCopy.sh +++ b/Scripts/Bash/Functions/Help/help_addNewFilesToWorkingCopy.sh @@ -32,7 +32,7 @@ function help_addNewFilesToWorkingCopy { # Restrict files addition to your working copy only. if [[ ! $LOCATION =~ '^/home/centos/artwork/' ]];then cli_printMessage "`gettext "Only files under /home/centos/artwork please."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Help --filter='help_addNewFilesToWorkingCopy.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Update your working copy first. diff --git a/Scripts/Bash/Functions/Help/help_createLanguageLayout.sh b/Scripts/Bash/Functions/Help/help_createLanguageLayout.sh index 6295799..c07ea87 100755 --- a/Scripts/Bash/Functions/Help/help_createLanguageLayout.sh +++ b/Scripts/Bash/Functions/Help/help_createLanguageLayout.sh @@ -48,7 +48,7 @@ function help_createLanguageLayout { read DOCTPL[${COUNTER}] if [[ ! $DOCTPL[${COUNTER}] =~ '[[:print:]]+' ]];then cli_printMessage "`gettext "The string entered isn't valid."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Help --filter='help_createLanguageLayout.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi COUNTER=$(($COUNTER + 1)) done diff --git a/Scripts/Bash/Functions/Help/help_getActions.sh b/Scripts/Bash/Functions/Help/help_getActions.sh index 475918e..a784fa8 100755 --- a/Scripts/Bash/Functions/Help/help_getActions.sh +++ b/Scripts/Bash/Functions/Help/help_getActions.sh @@ -52,7 +52,7 @@ function help_getActions { * ) cli_printMessage "`gettext "The option provided is not valid."`" - cli_printMessage "trunk/Manuals" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" ;; esac diff --git a/Scripts/Bash/Functions/Help/help_removeEntry.sh b/Scripts/Bash/Functions/Help/help_removeEntry.sh index 7992962..2befe7b 100755 --- a/Scripts/Bash/Functions/Help/help_removeEntry.sh +++ b/Scripts/Bash/Functions/Help/help_removeEntry.sh @@ -35,7 +35,7 @@ function help_removeEntry { if [[ ! -f $ENTRY ]];then cli_printMessage "`gettext "The following entry doesn't exist:"`" cli_printMessage "$ENTRY" "AsResponseLine" - cli_printMessage "trunk/Scripts/Bash/Functions/Help --filter='help_removeEntry.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Define entries. Start with the one being processed currently. diff --git a/Scripts/Bash/Functions/Help/help_searchIndex.sh b/Scripts/Bash/Functions/Help/help_searchIndex.sh index 42f0962..e2722e7 100644 --- a/Scripts/Bash/Functions/Help/help_searchIndex.sh +++ b/Scripts/Bash/Functions/Help/help_searchIndex.sh @@ -43,7 +43,7 @@ function help_searchIndex { # a regular expression pattern. if [[ ! "$REGEX" =~ $PATTERN ]];then cli_printMessage "`gettext "The search pattern is not valid."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Help --filter='help_searchIndex.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # There is no need to check the entry inside documentation diff --git a/Scripts/Bash/Functions/Help/help_updateOutputFiles.sh b/Scripts/Bash/Functions/Help/help_updateOutputFiles.sh index 201ab1a..b9e76df 100755 --- a/Scripts/Bash/Functions/Help/help_updateOutputFiles.sh +++ b/Scripts/Bash/Functions/Help/help_updateOutputFiles.sh @@ -40,7 +40,7 @@ function help_updateOutputFiles { # Check .info file. If the info file was not created then there # are errors to fix. if [[ ! -f ${MANUALS_FILE[4]} ]];then - cli_printMessage "trunk/Scripts/Bash/Functions/Help --filter='help_updateOutputFiles.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Compress .info file. diff --git a/Scripts/Bash/Functions/Locale/locale_doMessages.sh b/Scripts/Bash/Functions/Locale/locale_doMessages.sh index 25ff6a5..2eee900 100755 --- a/Scripts/Bash/Functions/Locale/locale_doMessages.sh +++ b/Scripts/Bash/Functions/Locale/locale_doMessages.sh @@ -77,7 +77,4 @@ function locale_doMessages { # Create machine object (.mo). msgfmt $PO_FILE --output=$MO_FILE - # Add new files inside TEXTDOMAINDIR to your working copy. - help_addNewFilesToWorkingCopy $TEXTDOMAINDIR - } diff --git a/Scripts/Bash/Functions/Locale/locale_getActions.sh b/Scripts/Bash/Functions/Locale/locale_getActions.sh index c41b917..918cc69 100644 --- a/Scripts/Bash/Functions/Locale/locale_getActions.sh +++ b/Scripts/Bash/Functions/Locale/locale_getActions.sh @@ -38,7 +38,7 @@ function locale_getActions { * ) cli_printMessage "`gettext "The option provided is not valid."`" - cli_printMessage "trunk/Scripts/Bash/Locale" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" esac diff --git a/Scripts/Bash/Functions/Render/render_checkConfig.sh b/Scripts/Bash/Functions/Render/render_checkConfig.sh index 0a2c3ce..5e210a7 100755 --- a/Scripts/Bash/Functions/Render/render_checkConfig.sh +++ b/Scripts/Bash/Functions/Render/render_checkConfig.sh @@ -31,7 +31,7 @@ function render_checkConfig { || [[ ! ${ACTIONS[0]} =~ '^(renderImage|renderText)$' ]];then cli_printMessage "`gettext "The ACTIONS[0] variable only supports the \\\"renderImage\\\" or \\\"renderText\\\" value."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_checkConfig.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi @@ -54,7 +54,7 @@ function render_checkConfig { || [[ ! -d "/home/centos/artwork/trunk/Identity/Themes/Models/$THEMEMODEL" ]];then cli_printMessage "`eval_gettext "The \\\"\\\$THEMEMODEL\\\" theme model doesn't exist."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_checkConfig.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi diff --git a/Scripts/Bash/Functions/Render/render_getActions.sh b/Scripts/Bash/Functions/Render/render_getActions.sh index 0243ee1..4d1a6bc 100644 --- a/Scripts/Bash/Functions/Render/render_getActions.sh +++ b/Scripts/Bash/Functions/Render/render_getActions.sh @@ -64,7 +64,7 @@ function render_getActions { else - cli_printMessage "trunk/Scripts/Bash" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi ;; diff --git a/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh b/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh index dda4f5b..ac24e83 100755 --- a/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh +++ b/Scripts/Bash/Functions/Render/render_getActionsIdentity.sh @@ -51,7 +51,7 @@ function render_getActionsIdentity { # here, so leave a message quit script execution. if [[ ! -d $ARTCONF ]];then cli_printMessage "`gettext "The path provided can't be processed."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getActionsIdentity.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi for FILE in $(find $ARTCONF -name 'render.conf.sh');do diff --git a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh index ed34b73..e765292 100755 --- a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh +++ b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh @@ -34,7 +34,7 @@ function render_getActionsTranslations { # exist leave a message and quit execution. if [[ ! -d $OPTIONVAL/Tpl ]];then cli_printMessage "`gettext "Can't find translation templates in the directory provided."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getActionsTranslations.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Check if there are pre-defined configuration scripts for the @@ -60,7 +60,7 @@ function render_getActionsTranslations { # that doesn't match release-specifc rendering translation # (the one done after this block), we need to end the # translation rendering right here. - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getActionsTranslations.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # ------------------------------------------------------------- @@ -120,7 +120,7 @@ function render_getActionsTranslations { # execution. if [[ $RELEASES == "" ]];then cli_printMessage "`gettext "There is not release-specific directory in the translation entry."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getActionsTranslations.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi for RELEASE in $RELEASES;do @@ -131,7 +131,7 @@ function render_getActionsTranslations { # Check release format. if [[ ! "$RELEASE" =~ "^${RELEASE_FORMAT}$" ]]; then cli_printMessage "`eval_gettext "The \\\"\\\$RELEASE\\\" release number isn't valid."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getActionsTranslations.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Define major and minor release format. diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh index b88d32c..51328d8 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh @@ -236,7 +236,7 @@ function render_getIdentityDefs { if [[ "$TEMPLATE" == '' ]];then cli_printMessage "`eval_gettext "No template defined for \\\$FILE."`" cli_printMessage "`gettext "Check the matching list (render_getIdentityMatchinglist) script."`" - cli_printMessage "trunk/Scripts/Bash/Functions/Render --filter='render_getIdentityDefs.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi fi diff --git a/Scripts/Bash/Functions/cli_checkFiles.sh b/Scripts/Bash/Functions/cli_checkFiles.sh index cfa6db9..636acb1 100644 --- a/Scripts/Bash/Functions/cli_checkFiles.sh +++ b/Scripts/Bash/Functions/cli_checkFiles.sh @@ -36,10 +36,10 @@ function cli_checkFiles { # be passed. if [[ $# -lt 1 ]];then cli_printMessage "`gettext "cli_checkFiles: At least one argument should be passed."`" - cli_printMessage "trunk/Scripts/Bash/Functions --filter='cli_checkFiles.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi - # If action is not specified, assume `Checking' as default. + # Define default action to take, if it is not specified. if [[ ! "$3" ]] || [[ "$3" == '' ]];then ACTION=`gettext "Checking"` fi @@ -89,7 +89,7 @@ function cli_checkFiles { # If there is some message print it and continue with the next # FILE in the loop (2). We wouldn't continue if a file is # missing. - if [ "$MESSAGE" == '' ];then + if [[ "$MESSAGE" == '' ]];then cli_printMessage "${ACTION}: $FILE" else cli_printMessage "${ACTION}: $MESSAGE" diff --git a/Scripts/Bash/Functions/cli_checkOptionValue.sh b/Scripts/Bash/Functions/cli_checkOptionValue.sh index ae32d98..61753a9 100755 --- a/Scripts/Bash/Functions/cli_checkOptionValue.sh +++ b/Scripts/Bash/Functions/cli_checkOptionValue.sh @@ -29,11 +29,11 @@ function cli_checkOptionValue { # Check option value before making an absolute path from it. if [[ $OPTIONVAL =~ '(\.\.(/)?)' ]];then cli_printMessage "`gettext "The path provided can't be processed."`" - cli_printMessage "trunk/Scripts/Bash/Functions --filter='cli_checkOptionValue.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi if [[ ! $OPTIONVAL =~ '^[A-Za-z0-9\./-]+$' ]];then cli_printMessage "`gettext "The path provided can't be processed."`" - cli_printMessage "trunk/Scripts/Bash/Functions --filter='cli_checkOptionValue.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Re-define option value to match the correct absolute path. As we @@ -63,7 +63,7 @@ function cli_checkOptionValue { else cli_printMessage "`gettext "The path provided is not a valid directory."`" - cli_printMessage "trunk/Scripts/Bash/Functions --filter='cli_checkOptionValue.sh" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi } diff --git a/Scripts/Bash/Functions/cli_getActions.sh b/Scripts/Bash/Functions/cli_getActions.sh index 132c4dd..1bd8a2e 100644 --- a/Scripts/Bash/Functions/cli_getActions.sh +++ b/Scripts/Bash/Functions/cli_getActions.sh @@ -41,7 +41,7 @@ function cli_getActions { # Check action existence. if [[ ! -f $ACTIONSCRIPT ]];then cli_printMessage "`gettext "The action provided is not valid."`" - cli_printMessage "trunk/Scripts/Bash" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi # Build action-specifc script file list. @@ -62,7 +62,7 @@ function cli_getActions { else cli_printMessage "`eval_gettext "The \\\$FILE hasn't execution rights."`" - cli_printMessage "trunk/Scripts/Bash" "AsToKnowMoreLine" + cli_printMessage "$(caller)" "AsToKnowMoreLine" fi diff --git a/Scripts/Bash/Functions/cli_printMessage.sh b/Scripts/Bash/Functions/cli_printMessage.sh index 803586a..c25f313 100755 --- a/Scripts/Bash/Functions/cli_printMessage.sh +++ b/Scripts/Bash/Functions/cli_printMessage.sh @@ -116,6 +116,13 @@ function cli_printMessage { ;; 'AsToKnowMoreLine' ) + # This option receives the output of bash's caller builtin + # as message value, in order to produce the documentation + # entry automatically. As caller builtin outputs the + # caller file path, documentation entry built from here is + # a file documentation entry. + MESSAGE=$(echo $MESSAGE | cut -d ' ' -f2-) + MESSAGE="$(dirname $MESSAGE)' --filter='$(basename $MESSAGE)" echo "`gettext "To know more, run"`: centos-art help --read='$MESSAGE'" exit ;;