From b45ddeff3e14a26174deb8fc292d6fcee62cc806 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: May 29 2011 19:31:53 +0000 Subject: Update `help' functionality: help.sh: - Separate execution of backend-related action names in three parts. One for actions that use all action values, other for actions that use just one action value and another for actions that don't use any action value at all. Backends/Docbook/docbook_getEntry.sh: - Start using FLAG_BACKEND in place of writing file extensions literllay. Backends/Texinfo/texinfo.sh: - Remove texinfo.sh file. Deam! This was what I initially intended to do, but forgot to specify the file location and all modified files were commited with the wrong comment. Backends/Texinfo/texinfo_updateNodes.sh: - Remove MANUAL_CHAPTER_DIR and MANUAL_CHAPTER_NAME variables. They are already defined in the help.sh file. Backends/Texinfo/texinfo_renameCrossReferences.sh: - Start using first and second positional parameters passed to this function as references to build the source (ENTRY_SRC) and target (ENTRY_DST) documentation entries. - Remove unused variables (e.g., NODE, COUNT). - Start using FALG_BACKEND variable as function suffix. Backends/Texinfo/texinfo_deleteEntry.sh: - Start using $@ instead of ${ACTIONVALS[*]}. - Remove MANUAL_CHAPTER_DIR variable definition. It has been already defined in help.sh. - Remove cli_syncroRepoChanges function invocation from here. It is has been already invocated in help.sh. - Don't perform pramble for deletion actions here (cli_printActionPreamble). This make the whole deletion process slower and interferes with file renaming actions. - Add file verification for ENTRIES, before deleting them. - Don't update output files here. They are already updated on help.sh. Backends/Texinfo/texinfo_getChapterDir.sh: - Support a list of entries here. Assuming more than one documentation entry be provided, a list of chapter directory is returned as output. Backends/Texinfo/texinfo_updateOutputFiles.sh: - Start using FLAG_BACKEND variable as suffix for invoking functions. Backends/Texinfo/texinfo_renameEntry.sh: - Start using FLAG_BACKEND variable as suffix for invoking functions. - Use function positional parameters as reference to perform the renaming action. Backends/Texinfo/texinfo_copyEntry.sh: - Use function positional parameters to restrict the amount of non-option arguments passed to centos-art.sh script. - Start using FLAG_BACKEND variable as suffix for invoking functions. - Use function positional parameters as reference to define the source (ENTRY_SRC) and target (ENTRY_DST) documentation entries. - Don't use version control verifications (e.g., cli_syncroRepoChanges and cli_commitRepoChanges) here. These actions are performed in help.sh already. - Don't force the existence of dependent directories for docuentation entries. Dependent directories are optional. Backends/Texinfo/texinfo_searchIndex.sh: - Rebuild output files to propagate recent changes. This is required because each time an index search is perform (through the `--search' option) all changes are braught from the repository to the working copy. So, in order to perform the index search in up to date files, we rebuilt the output files here. At this time, only texinfo backend, specifically its info output, seems to get benefit from this. Backends/Texinfo/texinfo_getEntry.sh: - Sanitate action value to use absolute paths. This let us create documentation entries from action values directly. There is no need to perform the sanitation elsewhere, the last purpose of the sanitation is build the documentation entry correctly. So, doing it here feels ok. Backends/Texinfo/texinfo_editEntry.sh: - Start using FLAG_BACKEND variable as suffix for invoking functions. - Don't update output files here. They are already updated on help.sh. Backends/Texinfo/texinfo_updateMenu.sh: - Remove MANUAL_CHAPTER_DIR and MANUAL_CHAPTER_NAME variables. They are already defined in the help.sh file. help_getOptions.sh: - Build the function definition file related to action name and verify its existence before initialize it. --- diff --git a/Scripts/Functions/Help/Backends/Docbook/docbook_getEntry.sh b/Scripts/Functions/Help/Backends/Docbook/docbook_getEntry.sh index f9440da..1aa7b5d 100755 --- a/Scripts/Functions/Help/Backends/Docbook/docbook_getEntry.sh +++ b/Scripts/Functions/Help/Backends/Docbook/docbook_getEntry.sh @@ -50,10 +50,10 @@ function docbook_getEntry { # structure. Otherwise, if an entry inside trunk/Manuals/ is # provided, the directory structure provided is used as default # documentation manual. - if [[ ${ENTRY} =~ "\.docbook$" ]];then - ENTRY=$(echo ${ENTRY} | sed 's!trunk/Manuals/Docbook/!!') + if [[ ${ENTRY} =~ "\.${FLAG_BACKEND}$" ]];then + ENTRY=$(echo ${ENTRY} | sed "s!trunk/Manuals/$(cli_getRepoName $FLAG_BACKEND -d)/!!") else - ENTRY=$(dirname Entities/Repository/Directories/${ENTRY})/$(basename $LOCATION).docbook + ENTRY=$(dirname Entities/Repository/Directories/${ENTRY})/$(basename $LOCATION).${FLAG_BACKEND} fi # Re-define entry to set absolute path to manuals base directory diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo.sh deleted file mode 100755 index 10f37ca..0000000 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# texinfo.sh -- This function redefines backend-specific variables. -# -# Copyright (C) 2009, 2010, 2011 The CentOS Project -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function texinfo { - - # Define documentation entry. - ENTRY=$(${FLAG_BACKEND}_getEntry) - - # Define directory to store documentation entries. - MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRY") - - # Define chapter name for documentation entry we're working with. - MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") - - # Define documentation entry directory. This is the directory - # where the entry file is stored. When the file extension be - # removed, consider that several backends could be used. - ENTRY_DIR=$(dirname ${ENTRY} | sed -r "s/\.${FLAG_BACKEND}$//") - - # Define documentation entry file (without extension). - ENTRY_FILE=$(basename ${ENTRY} | sed -r "s/\.${FLAG_BACKEND}$//") - - # Syncronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} - - # Verify action name against the file ought to be initialized - # from. If the file exists it is very sure that it has been - # already initialized, so execute the action name. Otherwise, if - # the file doesn't exist, print an error message. It is not - # possible to execute a function which definition hasn't been - # initialized. - if [[ -f ${FUNCDIR}/${FUNCDIRNAM}/${ACTIONNAM}.sh ]];then - $ACTIONNAM - else - cli_printMessage "`gettext "A valid action is required."`" --as-error-line - fi - - # Commit changes from working copy to central repository only. At - # this point, changes in the repository are not merged in the - # working copy, but chages in the working copy do are committed up - # to repository. - cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} - -} diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_copyEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_copyEntry.sh index d71e236..aacea09 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_copyEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_copyEntry.sh @@ -28,30 +28,22 @@ function texinfo_copyEntry { # Verify number of non-option arguments passed to centos-art.sh # script. - if [[ ${#ACTIONVALS[*]} -lt 2 ]];then + if [[ $# -lt 2 ]];then cli_printMessage "`gettext "Two paths are required."`" --as-error-line - elif [[ ${#ACTIONVALS[*]} -gt 2 ]];then + elif [[ $# -gt 2 ]];then cli_printMessage "`gettext "Only two paths are supported."`" --as-error-line fi - # Define source documentation entry. This is the documentation - # entry that will be duplicated. - local ENTRY_SRC=$(${FLAG_BACKEND}_getEntry ${ACTIONVALS[0]}) - - # Define directory where documentation entries are stored in. - local MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRY_SRC") - - # Syncronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} - # Print separator line. cli_printMessage '-' --as-separator-line + # Define source documentation entry. This is the documentation + # entry that will be duplicated. + local ENTRY_SRC=$(${FLAG_BACKEND}_getEntry "${1}") + # Define target documentation entry. This is the new documentation # entry created from the source documentation entry. - local ENTRY_DST=$(${FLAG_BACKEND}_getEntry "${ACTIONVALS[1]}") + local ENTRY_DST=$(${FLAG_BACKEND}_getEntry "${2}") # Verify parent directory of target documentation entry. If it # doesn't exist, create it and add it to version control. @@ -82,11 +74,7 @@ function texinfo_copyEntry { if [[ ! -a ${ENTRY_DST} ]];then cli_printMessage "${ENTRY_DST}" --as-creating-line svn cp "${ENTRY_SRC}" "${ENTRY_DST}" --quiet - else - cli_printMessage "`gettext "The target location is not valid."`" --as-error-line fi - else - cli_printMessage "`gettext "The source location is not valid."`" --as-error-line fi # Define list of target documentation entries. @@ -116,10 +104,4 @@ function texinfo_copyEntry { done - # Commit changes from working copy to central repository only. At - # this point, changes in the repository are not merged in the - # working copy, but chages in the working copy do are committed up - # to repository. - cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} - } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh index e03f1fd..4d0a227 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_deleteEntry.sh @@ -31,20 +31,7 @@ function texinfo_deleteEntry { # Define list of entries to remove using the entry specified in # the command line. - local ENTRIES=$(${FLAG_BACKEND}_getEntry "${ACTIONVALS[*]}") - - # Define path to directory where repository documentation entries - # are stored in. As reference, take the first non-option argument - # passed to centos-art.sh script. Since all action values point to - # directories inside the working copy, no matter what non-option - # argument do we use as reference to determine the manual chapter - # directory used to store documentation entries in. - local MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRIES") - - # Syncronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} + local ENTRIES=$(${FLAG_BACKEND}_getEntry "$@") # Print separator line. cli_printMessage '-' --as-separator-line @@ -84,14 +71,19 @@ function texinfo_deleteEntry { # Sanitate list of documentation entries that will be removed. ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq | tr "\n" ' ') - - # Print action preamble. - cli_printActionPreamble $ENTRIES --to-delete + # Verify existence of entries before deleting them. We cannot + # delete an entry which doesn't exist. Assuming that an entry + # doesn't exist, end script execution with an error message. + cli_checkFiles "$ENTRIES" + # Remove documentation entry using Subversion's `delete' command # to know when the action took place. Do not use regular `rm' # command here. - svn del ${ENTRIES} --quiet + for ENTRY in $ENTRIES;do + cli_printMessage "$ENTRY" --as-deleting-line + svn del ${ENTRY} --quiet + done # Verify exit status from subversion command to be sure everything # went well. Otherwise stop script execution with an error @@ -136,13 +128,4 @@ function texinfo_deleteEntry { done - # Commit changes from working copy to central repository only. At - # this point, changes in the repository are not merged in the - # working copy, but chages in the working copy do are committed up - # to repository. - cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} - - # Rebuild output files to propagate recent changes. - ${FLAG_BACKEND}_updateOutputFiles - } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_editEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_editEntry.sh index 312682d..b965a28 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_editEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_editEntry.sh @@ -57,11 +57,11 @@ function texinfo_editEntry { cli_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line # Update chapter section related menu. - texinfo_updateMenu + ${FLAG_BACKEND}_updateMenu # Update chapter section related nodes (based on chapter # section related menu). - texinfo_updateNodes + ${FLAG_BACKEND}_updateNodes # Update old missing cross references. If for some reason a # documentation entry is removed by mistake, and that mistake @@ -69,7 +69,7 @@ function texinfo_editEntry { # into the repository, rebuild the missing cross reference # message to use the correct link to the documentation # section. - texinfo_restoreCrossReferences + ${FLAG_BACKEND}_restoreCrossReferences else @@ -81,7 +81,4 @@ function texinfo_editEntry { # Use default text editor to edit the documentation entry. eval $EDITOR $ENTRY - # Rebuild output files to propagate recent changes. - texinfo_updateOutputFiles - } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_getChapterDir.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_getChapterDir.sh index 359e8f5..caac8fb 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_getChapterDir.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_getChapterDir.sh @@ -25,12 +25,8 @@ function texinfo_getChapterDir { - local ENTRY="$1" - - # Verify documentation entry. Only the first documentation entry - # provided must be used. This is for those cases where the first - # documentation entry needs to be retrived from a list of entries. - ENTRY=$(echo $ENTRY | cut -d ' ' -f 1) + local ENTRY='' + local ENTRIES="$1" # At this point, we need to take a desition about documentation # design, in order to answer the question: How do we assign @@ -43,8 +39,8 @@ function texinfo_getChapterDir { # something similar. Subsections and subsubsections will not have # their own files, they all will be written inside the same # section file that represents the repository documentation entry. - if [[ $ENTRY != '' ]];then - echo $ENTRY | cut -d / -f-8 - fi + for ENTRY in $ENTRIES;do + ${FLAG_BACKEND}_getEntry $ENTRY | cut -d / -f-8 + done | sort | uniq } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_getEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_getEntry.sh index 913843b..e8d889a 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_getEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_getEntry.sh @@ -42,6 +42,9 @@ function texinfo_getEntry { fi for LOCATION in $LOCATIONS;do + + # Sanitate action value to use absolute paths. + cli_checkRepoDirSource $LOCATION # Define relative path of entry, from trunk directory on. ENTRY=$(echo $LOCATION | sed -r "s!^${HOME}/artwork/!!") diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameCrossReferences.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameCrossReferences.sh index c832ba0..58ed2ca 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameCrossReferences.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameCrossReferences.sh @@ -26,28 +26,25 @@ function texinfo_renameCrossReferences { - local NODE='' - local COUNT=1 - local ENTRIES='' - local NODE_SRC='' - local NODE_DST='' + local ENTRY_SRC=$(${FLAG_BACKEND}_getEntry "$1") + local ENTRY_DST=$(${FLAG_BACKEND}_getEntry "$2") # Define node pattern for source documenation entry. - NODE_SRC=$(echo "$ENTRY" \ + local NODE_SRC=$(echo "$ENTRY_SRC" \ | cut -d / -f8- \ | tr '/' ' ' \ | sed -r \ -e "s/(chapter-intro\.${FLAG_BACKEND}|\.${FLAG_BACKEND})$//") # Define node replacement for target documentation entry. - NODE_DST=$(echo "$ENTRY_DST" \ + local NODE_DST=$(echo "$ENTRY_DST" \ | cut -d / -f8- \ | tr '/' ' ' \ | sed -r \ -e "s/(chapter-intro\.${FLAG_BACKEND}|\.${FLAG_BACKEND})$//") # Define list of entries to process. - ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern=".*\.${FLAG_BACKEND}") + local ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} --pattern=".*\.${FLAG_BACKEND}") # Update node-related cross-references. The node-related cross # reference definition, long ones specially, could require more @@ -65,6 +62,6 @@ function texinfo_renameCrossReferences { # source to target documentation entry, but they are still # commented. So, uncomment them restoring target documentation # entries. - texinfo_restoreCrossReferences "${ENTRY_DST}" + ${FLAG_BACKEND}_restoreCrossReferences "${ENTRY_DST}" } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameEntry.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameEntry.sh index 43bf04e..67cdadb 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameEntry.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_renameEntry.sh @@ -26,17 +26,17 @@ function texinfo_renameEntry { # Copy source documentation entry. - texinfo_copyEntry + ${FLAG_BACKEND}_copyEntry "$1" "$2" # Delete source documentation entry. The source documentation # entry has been copied already, so to create the rename effect # delete it from repository filesystem. - texinfo_deleteEntry + ${FLAG_BACKEND}_deleteEntry $1 # At this point, source documentation entry has been removed and # all menu, nodes and cross-references have been commented. So, # replace commented menu, nodes and cross-reference information # from source to target documentation entry. - texinfo_renameCrossReferences + ${FLAG_BACKEND}_renameCrossReferences "$1" "$2" } diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_searchIndex.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_searchIndex.sh index b701660..49a4ea4 100644 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_searchIndex.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_searchIndex.sh @@ -25,6 +25,12 @@ function texinfo_searchIndex { + # Rebuild output files to propagate recent changes. + ${FLAG_BACKEND}_updateOutputFiles + + # Print separator line. + cli_printMessage '-' --as-separator-line + # Print action message. cli_printMessage "${MANUAL_BASEFILE}.info.bz2" --as-reading-line diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateMenu.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateMenu.sh index f33b105..9165d79 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateMenu.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateMenu.sh @@ -39,12 +39,6 @@ function texinfo_updateMenu { local MENUNODE=$(echo "$ENTRY" | cut -d / -f9- | tr '/' ' ' \ | sed "s/\.${FLAG_BACKEND}$//") - # Define directory to store documentation entries. - local MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRY") - - # Define chapter name for documentation entry we're working with. - local MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") - # Give format to menu line using texinfo style. local MENULINE="* ${MANUAL_CHAPTER_NAME} $MENUNODE::" diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateNodes.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateNodes.sh index d1868e6..20ea0e7 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateNodes.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateNodes.sh @@ -27,12 +27,6 @@ function texinfo_updateNodes { local TEXINFO_TEMPLATE='' - # Define directory to store documentation entries. - local MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$ENTRY") - - # Define chapter name for documentation entry we're working with. - local MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") - # Retrive nodes' entries from chapter-menu.texinfo file. local NODES=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.${FLAG_BACKEND} \ | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \ diff --git a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateOutputFiles.sh b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateOutputFiles.sh index 9e44c62..25f91f3 100755 --- a/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateOutputFiles.sh +++ b/Scripts/Functions/Help/Backends/Texinfo/texinfo_updateOutputFiles.sh @@ -33,11 +33,11 @@ function texinfo_updateOutputFiles { # paths incorrectly. pushd ${HOME}/artwork > /dev/null - texinfo_updateOutputFileInfo - texinfo_updateOutputFileXhtml - texinfo_updateOutputFileXml - texinfo_updateOutputFilePdf - texinfo_updateOutputFilePlaintext + ${FLAG_BACKEND}_updateOutputFileInfo + ${FLAG_BACKEND}_updateOutputFileXhtml + ${FLAG_BACKEND}_updateOutputFileXml + ${FLAG_BACKEND}_updateOutputFilePdf + ${FLAG_BACKEND}_updateOutputFilePlaintext # Remove the working copy root directory from directory stack. popd > /dev/null diff --git a/Scripts/Functions/Help/help.sh b/Scripts/Functions/Help/help.sh index e022f5f..c7155b8 100755 --- a/Scripts/Functions/Help/help.sh +++ b/Scripts/Functions/Help/help.sh @@ -28,7 +28,6 @@ function help { local ACTIONNAM='' local ACTIONVAL='' - local -a ACTIONVALS # Initialize the search option. The search option (`--search') # specifies the pattern used inside info files when an index @@ -78,43 +77,92 @@ function help { cli_printMessage "`gettext "The backend provided is not supported."`" --as-error-line fi - # Store remaining arguments into an array. This way it is possible - # to find out which is the last argument in the list. When - # copying files inside the repository, the last argument in the - # list is considered the target location and all other arguments - # are considered the source locations. Similary, when renaming - # files, only two arguments can be passed. - for ACTIONVAL in "$@";do - - # Sanitate action value. - cli_checkRepoDirSource - - # Assign sanitated action vlue. - ACTIONVALS[((++${#ACTIONVALS[*]}))]=$ACTIONVAL - - done - # Execute backend functionalities. Notice that there are # functionalities that need more than one action value in order to - # be executed (eg. copying, and renaming) and functionalities + # be executed (e.g., copying, and renaming), functionalities # that need just one action value to be executed (e.g., - # documentation reading and edition). This way, the execution of - # backend functionalities is splitted here. + # documentation reading and edition) and functionalities that + # don't need action value at all (e.g., searching and updating + # output files). This way, the execution of backend + # functionalities is splitted here. if [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(copy|rename|delete)Entry" ]];then + # Define directories where documentation entries are stored + # in. Since more than one action value might be affected + # here, more than one directory might be considered as chapter + # directory, as well. + MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "$@") + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. + cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} + # Execute backend action names that may need to use more than # one action value. - ${ACTIONNAM} + ${ACTIONNAM} $@ + + # Commit changes from working copy to central repository only. + # At this point, changes in the repository are not merged in + # the working copy, but chages in the working copy do are + # committed up to repository. + cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} + + elif [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(searchIndex|updateOutputFiles)" ]];then + + # Bring changes from the repository to the working copy. + cli_updateRepoChanges ${MANUAL_BASEDIR} + + # Execute backend action names that don't need to use any + # action value as reference to do their work. + $ACTIONNAM + + # Backend action names that don't need to use any action value + # as reference to do their work are of one-pass only. They are + # executed and then the script execution is finished. + exit else # Execute backend action names that use one action value, only. - for ACTIONVAL in ${ACTIONVALS[@]};do - ${FLAG_BACKEND} + for ACTIONVAL in $@;do + + # Define directories where documentation entries are + # stored in. Since just one action value is + # affected here, just one directory is considered as + # chapter directory, as well. + MANUAL_CHAPTER_DIR=$(${FLAG_BACKEND}_getChapterDir "${ACTIONVAL}") + + # Define chapter name for documentation entry we're working with. + MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR") + + # Define documentation entry. + ENTRY=$(${FLAG_BACKEND}_getEntry $ACTIONVAL) + + # Syncronize changes between repository and working copy. + # At this point, changes in the repository are merged in + # the working copy and changes in the working copy + # committed up to repository. + cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR} + + # Execute backend action names that may need to use more + # than one action value. + $ACTIONNAM + + # Commit changes from working copy to central repository + # only. At this point, changes in the repository are not + # merged in the working copy, but chages in the working + # copy do are committed up to repository. + cli_commitRepoChanges ${MANUAL_CHAPTER_DIR} + done fi + # Rebuild output files to propagate recent changes. + ${FLAG_BACKEND}_updateOutputFiles + # Perform language-specific actions when the current language is # other but English language. if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then diff --git a/Scripts/Functions/Help/help_getOptions.sh b/Scripts/Functions/Help/help_getOptions.sh index 16da026..6a07140 100755 --- a/Scripts/Functions/Help/help_getOptions.sh +++ b/Scripts/Functions/Help/help_getOptions.sh @@ -135,6 +135,14 @@ function help_getOptions { # the function (e.g., help_getEntry). ACTIONNAM="${FLAG_BACKEND}_${ACTIONNAM}" + # Verify action name. It is required that the action name + # specified does have a definition file. Otherwise it is a action + # name valid, but not supported yet (e.g., it needs to be + # written). + if [[ ! -f ${FUNCDIR}/${FUNCDIRNAM}/${ACTIONNAM}.sh ]];then + cli_printMessage "`gettext "The action provided is not supported yet."`" --as-error-line + fi + # Redefine ARGUMENTS variable using current positional parameters. cli_parseArgumentsReDef "$@"