Blame Scripts/Functions/Help/help_getEntry.sh

4c79b5
#!/bin/bash
4c79b5
#
0211a4
# help_getEntry.sh -- This function builds a documentation entry based
638bf8
# on a location specified. Location specification can be both action
638bf8
# value (ACTIONVAL) variable or a value passed as first positional
638bf8
# parameter.
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
fa95b1
# the Free Software Foundation; either version 2 of the License, or
fa95b1
# (at your option) any later version.
fa95b1
#
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
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
0211a4
function help_getEntry {
4c79b5
4c79b5
    # Define variables as local to avoid conflicts outside.
4c79b5
    local ENTRY=''
638bf8
    local LOCATION=''
638bf8
638bf8
    # Redefine location in order to make this function reusable not
638bf8
    # just for action value variable but whatever value passed as
638bf8
    # first possitional argument.
638bf8
    if [[ "$1" != '' ]];then
638bf8
        LOCATION="$1"
638bf8
    else
638bf8
        LOCATION="$ACTIONVAL"
638bf8
    fi
4c79b5
5285d6
    # Define relative path of entry, from trunk directory on.
5285d6
    ENTRY=$(echo $LOCATION | sed -r "s!^${HOME}/artwork/!!")
4c79b5
5285d6
    # Verify the entry relative path to find out which documentation
5285d6
    # manual we are acting on. As convenction, whatever documentation
8599c5
    # entry you provide outside trunk/Identity/Manuals/ directory
8599c5
    # structure is considered as you are documenting the repository
8599c5
    # directory structure. Otherwise, if an entry inside
8599c5
    # trunk/Identity/Manuals/ is provided, the directory structure
8599c5
    # provided is used as default documentation manual for actions
8599c5
    # like `--create' and `--update' to take place on. Other options
8599c5
    # like `--edit', `--delete' and `--read' cannot be applied to
8599c5
    # paths provided inside trunk/Identity/Manuals/ such actions need
8599c5
    # to be performed manually.
966109
    if [[ ${ENTRY} =~ '\.texi$' ]];then
8599c5
        ENTRY=$(echo ${ENTRY} | sed 's!trunk/Identity/Manual/!!')
5285d6
    else
18bc8c
        ENTRY=$(dirname Directories/${ENTRY})/$(basename $LOCATION).texi
5285d6
    fi
4c79b5
5285d6
    # Re-define entry to set absolute path to manuals base directory
5285d6
    # structure.
5285d6
    ENTRY=${MANUAL_BASEDIR}/${ENTRY}
4c79b5
4c79b5
    # Output entry's absolute path.
5285d6
    echo ${ENTRY}
4c79b5
4c79b5
}