Blame Scripts/Functions/Help/help_deleteEntry.sh

4c79b5
#!/bin/bash
4c79b5
#
0211a4
# help_deleteEntry.sh -- This function removes a documentation entry
5285d6
# from documentation directory structure.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
0211a4
function help_deleteEntry {
4c79b5
635e5d
    # Print separator line.
635e5d
    cli_printMessage '-' 'AsSeparatorLine'
635e5d
3385aa
    local ENTRY_SRC=${ENTRY}
4c79b5
    local ENTRIES=''
3385aa
    local ENTRY=''
3385aa
    local ENTRY_DEP=''
4c79b5
449927
    # Initiate list of entries to remove using the entry specified in
449927
    # the command line.
3385aa
    ENTRIES=${ENTRY_SRC}
449927
449927
    # Verify existence of dependent entries.  Dependent entries are
449927
    # stored inside a directory with the same name of the entry you
449927
    # are trying to remove.
449927
    if [[ -d ${ENTRY_DIR}/${ENTRY_FILE} ]];then
449927
3385aa
        # Add dependent files to list of entries. 
449927
        ENTRIES="${ENTRIES} $(cli_getFilesList "${ENTRY_DIR}/${ENTRY_FILE}" ".*\.texi")"
449927
3385aa
        # Add dependent directories to list of entries. Be aware of
3385aa
        # nested directories.
3385aa
        for ENTRY in ${ENTRIES};do
3385aa
            ENTRY_DEP=$(echo $ENTRY | sed -r "s/\.texi$//")
3385aa
            if [[ -d $ENTRY_DEP ]];then
3385aa
                ENTRIES="${ENTRIES} ${ENTRY_DEP}"
3385aa
            fi
3385aa
        done
4c79b5
4c79b5
    fi
4c79b5
449927
    # Prepare list of entries for action preamble.
3385aa
    ENTRIES=$(echo ${ENTRIES} | tr ' ' "\n" | sort -r | uniq)
5285d6
    
638bf8
    # Print action preamble.
638bf8
    cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine'
638bf8
635e5d
    # Remove documentation entry using Subversion's `delete' command
635e5d
    # to know when the action took place.  Do not use regular `rm'
635e5d
    # command here.
3385aa
    svn del ${ENTRIES} --quiet
635e5d
635e5d
    # Verify exit status from subversion command to be sure everything
635e5d
    # went well. Otherwhise stop script execution.
136786
    if [[ $? -ne 0 ]];then
eee226
        cli_printMessage "${FUNCDIRNAM}" 'AsToKnowMoreLine'
136786
    fi
4456e8
449927
    # Print separator line.
449927
    cli_printMessage '-' 'AsSeparatorLine'
449927
449927
    # Print action message.
635e5d
    cli_printMessage "Updating menus, nodes and cross-references." 'AsResponseLine'
449927
449927
    # Process list of entries in order to update menus, nodes and
449927
    # cross references. Since we are verifying entry status before
449927
    # remove the we cannot update the information in the same loop we
449927
    # remove files. This would modify some file before be removed and
449927
    # that would stop script execution. Similary, if we do update
449927
    # menus, nodes and cross references before removing files it would
449927
    # be needed to remove farther status verification in order for the
449927
    # script to continue its execution. Thereby, I can't see a
449927
    # different way but removing files first using status verification
635e5d
    # and later go through entries list again to update menus, nodes
635e5d
    # and cross references in remaining files.
3385aa
    for ENTRY in ${ENTRIES};do
3385aa
449927
        # Update menu and node definitions from manual sections to
449927
        # reflect the changes.
0211a4
        help_updateMenu "remove-entry"
0211a4
        help_updateNodes
4456e8
449927
        # Update cross reference definitions from manual to reflect
449927
        # the changes.
0211a4
        help_deleteCrossReferences
f8fb31
4456e8
    done
4456e8
 
635e5d
    # Rebuild output files to propagate recent changes.
635e5d
    help_updateOutputFiles
4c79b5
4c79b5
}