|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
2bd980 |
# manual_getActions.sh -- This function interpretes arguments passed
|
|
|
2bd980 |
# to `manual' functionality and calls actions accordingly.
|
|
|
4c79b5 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# 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
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4de5d4 |
function manual_getActions {
|
|
|
4c79b5 |
|
|
|
2bd980 |
# Define short options we want to support.
|
|
|
2bd980 |
local ARGSS=""
|
|
|
2bd980 |
|
|
|
2bd980 |
# Define long options we want to support.
|
|
|
9f4d86 |
local ARGSL="read:,search:,edit:,delete:,update:,copy:,rename:,to:"
|
|
|
2bd980 |
|
|
|
2bd980 |
# Parse arguments using getopt(1) command parser.
|
|
|
2bd980 |
cli_doParseArguments
|
|
|
2bd980 |
|
|
|
2bd980 |
# Reset positional parameters using output from (getopt) argument
|
|
|
2bd980 |
# parser.
|
|
|
2bd980 |
eval set -- "$ARGUMENTS"
|
|
|
2bd980 |
|
|
|
2bd980 |
# Define action to take for each option passed.
|
|
|
2bd980 |
while true; do
|
|
|
2bd980 |
case "$1" in
|
|
|
2bd980 |
|
|
|
638bf8 |
--read )
|
|
|
2bd980 |
ACTIONVAL="$2"
|
|
|
638bf8 |
ACTIONNAM="${FUNCNAM}_searchNode"
|
|
|
638bf8 |
shift 2
|
|
|
638bf8 |
;;
|
|
|
638bf8 |
|
|
|
638bf8 |
--search )
|
|
|
638bf8 |
ACTIONVAL="$2"
|
|
|
2bd980 |
ACTIONNAM="${FUNCNAM}_searchIndex"
|
|
|
638bf8 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
2bd980 |
--edit )
|
|
|
2bd980 |
ACTIONVAL="$2"
|
|
|
2bd980 |
ACTIONNAM="${FUNCNAM}_editEntry"
|
|
|
638bf8 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
2bd980 |
--delete )
|
|
|
2bd980 |
ACTIONVAL="$2"
|
|
|
742c46 |
ACTIONNAM="${FUNCNAM}_deleteEntry"
|
|
|
638bf8 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
638bf8 |
--update )
|
|
|
5285d6 |
ACTIONVAL="$2"
|
|
|
5285d6 |
ACTIONNAM="${FUNCNAM}_updateOutputFiles"
|
|
|
5285d6 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
638bf8 |
--copy )
|
|
|
2bd980 |
ACTIONVAL="$2"
|
|
|
638bf8 |
ACTIONNAM="${FUNCNAM}_copyEntry"
|
|
|
638bf8 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
2bd980 |
|
|
|
9f4d86 |
--rename )
|
|
|
9f4d86 |
ACTIONVAL="$2"
|
|
|
9f4d86 |
ACTIONNAM="${FUNCNAM}_renameEntry"
|
|
|
9f4d86 |
shift 2
|
|
|
9f4d86 |
;;
|
|
|
9f4d86 |
|
|
|
638bf8 |
--to )
|
|
|
01ae87 |
FLAG_TO="$(manual_getEntry "$2")"
|
|
|
638bf8 |
shift 2
|
|
|
638bf8 |
;;
|
|
|
2bd980 |
|
|
|
2bd980 |
* )
|
|
|
638bf8 |
# Break options loop.
|
|
|
2bd980 |
break
|
|
|
2bd980 |
esac
|
|
|
2bd980 |
done
|
|
|
2bd980 |
|
|
|
638bf8 |
# Check action value passed through the command-line using source
|
|
|
638bf8 |
# directory definition as reference.
|
|
|
638bf8 |
cli_checkRepoDirSource
|
|
|
2bd980 |
|
|
|
2bd980 |
# Define documentation entry.
|
|
|
2bd980 |
ENTRY=$(manual_getEntry)
|
|
|
2bd980 |
|
|
|
01ae87 |
# Define documentation entry directory. This is the directory
|
|
|
01ae87 |
# where the entry file is stored.
|
|
|
01ae87 |
ENTRY_DIR=$(dirname ${ENTRY} | sed -r 's!\.texi$!!')
|
|
|
01ae87 |
|
|
|
01ae87 |
# Define documentation entry file (without extension).
|
|
|
01ae87 |
ENTRY_FILE=$(basename ${ENTRY} | sed -r 's!\.texi$!!')
|
|
|
01ae87 |
|
|
|
b6fafb |
# Define file name for documentation manual. This is the file used
|
|
|
b6fafb |
# to initiate the structure of documentation manual.
|
|
|
759d18 |
MANUAL_NAME=repository
|
|
|
b6fafb |
|
|
|
5285d6 |
# Define directory to store documentation entries. At this point,
|
|
|
5285d6 |
# we need to take a desition about documentation design, in order
|
|
|
5285d6 |
# to answer the question: How do we assign chapters, sections and
|
|
|
5285d6 |
# subsections automatically, based on the repository structure?
|
|
|
5285d6 |
# and also, how such design could be adapted to changes in the
|
|
|
5285d6 |
# repository structure?
|
|
|
2bd980 |
#
|
|
|
759d18 |
# One solution would be: represent the repository's directory
|
|
|
759d18 |
# structure as sections inside a chapter named Filesystem or
|
|
|
759d18 |
# something similar. Subsections and subsubsections will not have
|
|
|
759d18 |
# their own files, they all will be written inside the same
|
|
|
759d18 |
# section file that represents the repository directory.
|
|
|
759d18 |
MANUAL_CHAPTER_DIR=$(echo $ENTRY | cut -d / -f-7)
|
|
|
5285d6 |
|
|
|
5285d6 |
# Define chapter name for the documentation entry we are working
|
|
|
5285d6 |
# with.
|
|
|
7f7f8f |
MANUAL_CHAPTER_NAME=$(basename "$MANUAL_CHAPTER_DIR")
|
|
|
2bd980 |
|
|
|
01ae87 |
# Define base name for documentation manual files (without
|
|
|
01ae87 |
# extension). This is the main file name used to build texinfo
|
|
|
01ae87 |
# related files (.info, .pdf, .xml, etc.).
|
|
|
759d18 |
MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}"
|
|
|
b6fafb |
|
|
|
b6fafb |
# Set action preable.
|
|
|
01ae87 |
cli_printActionPreamble "${MANUAL_BASEFILE}.texi"
|
|
|
2bd980 |
|
|
|
b88dec |
# Syncronize changes between the working copy and the central
|
|
|
b88dec |
# repository to bring down changes.
|
|
|
759d18 |
cli_syncroRepoChanges ${MANUAL_BASEDIR}
|
|
|
b88dec |
|
|
|
2bd980 |
# Execute action name.
|
|
|
2bd980 |
if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
|
|
|
2bd980 |
eval $ACTIONNAM
|
|
|
2bd980 |
else
|
|
|
2bd980 |
cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine'
|
|
|
2bd980 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
2bd980 |
fi
|
|
|
4c79b5 |
|
|
|
b88dec |
# Syncronize changes between the working copy and the central
|
|
|
b88dec |
# repository to commit up changes.
|
|
|
759d18 |
cli_commitRepoChanges ${MANUAL_BASEDIR}
|
|
|
b88dec |
|
|
|
4c79b5 |
}
|