diff --git a/Scripts/Bash/Functions/Manual/manual.sh b/Scripts/Bash/Functions/Manual/manual.sh index 536b13d..c6e3c28 100755 --- a/Scripts/Bash/Functions/Manual/manual.sh +++ b/Scripts/Bash/Functions/Manual/manual.sh @@ -27,6 +27,10 @@ function manual { + # Define default value to target flag. The target flag (--to) + # controls final destination used by copy related actions. + local FLAG_TO='' + # Define documentation base directory structure. MANUALS_DIR[0]='/home/centos/artwork/trunk/Manuals' MANUALS_DIR[1]=${MANUALS_DIR[0]}/$(cli_getCurrentLocale) diff --git a/Scripts/Bash/Functions/Manual/manual_getActions.sh b/Scripts/Bash/Functions/Manual/manual_getActions.sh index 3f3640f..51650a3 100755 --- a/Scripts/Bash/Functions/Manual/manual_getActions.sh +++ b/Scripts/Bash/Functions/Manual/manual_getActions.sh @@ -33,7 +33,7 @@ function manual_getActions { local ARGSS="" # Define long options we want to support. - local ARGSL="search:,edit:,delete:,update-output,update-structure:,read:" + local ARGSL="read:,search:,edit:,delete:,update,copy:,to:,quiet,yes" # Parse arguments using getopt(1) command parser. cli_doParseArguments @@ -46,20 +46,28 @@ function manual_getActions { while true; do case "$1" in - --search ) + --read ) # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_searchNode" + + # Rotate positional parameters. + shift 2 + ;; + + --search ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" # Define action name using action value as reference. ACTIONNAM="${FUNCNAM}_searchIndex" - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; --edit ) @@ -67,15 +75,11 @@ function manual_getActions { # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - # Define action name using action value as reference. ACTIONNAM="${FUNCNAM}_editEntry" - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; --delete ) @@ -83,18 +87,14 @@ function manual_getActions { # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - # Define action name. ACTIONNAM="${FUNCNAM}_removeEntry" - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; - --update-output ) + --update ) # Execute action name. There is no need of action # value here, so let's execute the action right now. @@ -104,47 +104,54 @@ function manual_getActions { break ;; - --update-structure ) + --copy ) # Define action value passed through the command-line. ACTIONVAL="$2" - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_updateTexinfoStructure" + ACTIONNAM="${FUNCNAM}_copyEntry" - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; - --read ) + --to ) + + # Redefine target flag. + FLAG_TO="$2" - # Define action value passed through the command-line. - ACTIONVAL="$2" + # Rotate positional parameters. + shift 2 + ;; - # Check action value passed through the command-line - # using source directory definition as reference. - cli_checkRepoDirSource + --quiet ) + + # Redefine target flag. + FLAG_QUIET='true' - # Define action name using action value as reference. - ACTIONNAM="${FUNCNAM}_searchNode" + # Rotate positional parameters. + shift 1 + ;; - # Break options loop. - break + --yes ) + + # Redefine target flag. + FLAG_YES='true' + + # Rotate positional parameters. + shift 1 ;; * ) + # Break options loop. break esac done - # Verify action value variable. - if [[ $ACTIONVAL == '' ]];then - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi + # Check action value passed through the command-line using source + # directory definition as reference. + cli_checkRepoDirSource # Define documentation entry. ENTRY=$(manual_getEntry) diff --git a/Scripts/Bash/Functions/Manual/manual_getEntry.sh b/Scripts/Bash/Functions/Manual/manual_getEntry.sh index b90bfe8..50f626f 100755 --- a/Scripts/Bash/Functions/Manual/manual_getEntry.sh +++ b/Scripts/Bash/Functions/Manual/manual_getEntry.sh @@ -1,7 +1,9 @@ #!/bin/bash # # manual_getEntry.sh -- This function builds a documentation entry based -# on action value (ACTIONVAL) variable. +# on a location specified. Location specification can be both action +# value (ACTIONVAL) variable or a value passed as first positional +# parameter. # # Copyright (C) 2009-2011 Alain Reguera Delgado # @@ -30,14 +32,24 @@ function manual_getEntry { local DIR='' local FILE='' local ENTRY='' + local LOCATION='' + + # Redefine location in order to make this function reusable not + # just for action value variable but whatever value passed as + # first possitional argument. + if [[ "$1" != '' ]];then + LOCATION="$1" + else + LOCATION="$ACTIONVAL" + fi # Build directory for documenation entry. - DIR=$(echo $ACTIONVAL | sed -r 's!^/home/centos/artwork/!!') + DIR=$(echo $LOCATION | sed -r 's!^/home/centos/artwork/!!') DIR=$(dirname $DIR) DIR=${MANUALS_DIR[2]}/$DIR # Build file for documentation entry. - FILE=$(basename $ACTIONVAL).texi + FILE=$(basename $LOCATION).texi # Combine both directory (DIR) and file (FILE) to build entry's # absolute path. When the entry's absolute path is built for the diff --git a/Scripts/Bash/Functions/Manual/manual_removeEntry.sh b/Scripts/Bash/Functions/Manual/manual_removeEntry.sh index 2733f09..8a9a925 100755 --- a/Scripts/Bash/Functions/Manual/manual_removeEntry.sh +++ b/Scripts/Bash/Functions/Manual/manual_removeEntry.sh @@ -28,17 +28,10 @@ function manual_removeEntry { # Define variables as local to avoid conflicts outside. local ENTRIES='' - local ENTRIES_COUNTER=1 local LOCATION='' - # Check changes in the working copy. - cli_commitRepoChanges "$ENTRY" - # Check if the entry has been already removed. - if [[ ! -f $ENTRY ]];then - cli_printMessage "`eval_gettext "The entry \\\`\\\$ENTRY' doesn't exist."`" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi + cli_checkFiles $ENTRY 'f' # Define entries. Start with the one being processed currently. ENTRIES=$ENTRY @@ -46,9 +39,9 @@ function manual_removeEntry { # Define root location to look for entries. LOCATION=$(echo $ENTRY | sed -r 's!\.texi$!!') - # Re-define location to match the chapter's root directory. This + # Redefine location to match the chapter's root directory. This # applies when you try to remove the whole chapter from the - # working copy (e.g., centos-art manual --remove=/home/centos/artwork/trunk/). + # working copy (e.g., centos-art manual --delete=/home/centos/artwork/trunk/). if [[ $ENTRY =~ "${MANUALS_FILE[7]}$" ]];then LOCATION=$(dirname $ENTRY) fi @@ -62,63 +55,53 @@ function manual_removeEntry { if [[ -d $LOCATION ]];then for ENTRY in $(find $LOCATION -name '*.texi');do ENTRIES="$ENTRIES $ENTRY $(dirname $ENTRY)" - ENTRIES_COUNTER=$(($ENTRIES_COUNTER + 1)) done fi # Remove duplicated lines from entries list. ENTRIES=$(echo "$ENTRIES" | tr ' ' "\n" | sort -r | uniq) - # Show a verification message before doing anything. - cli_printMessage "`ngettext "The following entry will be deleted" \ - "The following entries will be deleted" $ENTRIES_COUNTER`:" - - # Show list of affected entries. + # Print action preamble. + cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine' + + # Redefine ENTRY using affected entries as reference. for ENTRY in $ENTRIES;do - cli_printMessage "$ENTRY" "AsResponseLine" - done - cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine" + # Verify entry inside the working copy. + if [[ $(cli_getRepoStatus "$ENTRY") =~ '^( |\?)' ]];then - # Re-define ENTRY using affected entries as reference. - for ENTRY in $ENTRIES;do + # Print action message. + cli_printMessage "$ENTRY" "AsDeletingLine" + + else - # Show which entry is being removed. - cli_printMessage "$ENTRY" "AsDeletingLine" + # Do not remove a versioned documentation entry with + # changes inside. Print a message about it and stop script + # execution instead. + cli_printMessage "`gettext "There are pendent changes that need to be committed first."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + + fi # Remove documentation entry. At this point, documentation # entry can be under version control or not versioned at all. # Here we need to decide how to remove documentation entries - # based on whether they are under version control or not. + # based on wether they are under version control or not. if [[ "$(cli_getRepoStatus "$ENTRY")" == ' ' ]];then - # Documentation entry is under version control and clean - # of changes. Only if documentation entry is clean of - # changes we can mark it for deletion. So use subversion's - # `del' command to do so. + # Documentation entry is under version control and there + # is no change to be commited up to central repository. We + # are safe to schedule it for deletion. svn del "$ENTRY" --quiet elif [[ "$(cli_getRepoStatus "$ENTRY")" == '?' ]];then # Documentation entry is not under version control, so we - # don't care about changes inside unversioned - # documentation entries at all. If you say centos-art.sh - # script to remove an unversion documentation entry it - # will do so, using convenctional `rm' command. - if [[ -d "$ENTRY" ]];then - rm -r "$ENTRY" - else - rm "$ENTRY" - fi - - else - - # Documentation entry is under version control and it does - # have changes. We don't remove a versioned documentation - # entry with changes. So print a message about it and stop - # script execution. - cli_printMessage "`eval_gettext "The entry \\\`\\\$ENTRY' cannot be deleted."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' + # don't care about changes inside it. If you say + # centos-art.sh script to remove an unversion + # documentation entry it will do so, using convenctional + # `rm' command. + rm -r "$ENTRY" fi @@ -140,7 +123,4 @@ function manual_removeEntry { manual_updateChaptersNodes fi - # Update manuals' related output files. - manual_updateOutputFiles - }