Blame Scripts/Functions/Help/help_getEntries.sh

e82789
#!/bin/bash
e82789
#
e82789
# help_getEntries.sh -- This function interpretes non-option
e82789
# arguments passed to `help' functionality through the command-line
e82789
# and redefines array variables related to documentation entries.
e82789
#
e82789
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
e82789
#
e82789
# This program is free software; you can redistribute it and/or modify
e82789
# it under the terms of the GNU General Public License as published by
e82789
# the Free Software Foundation; either version 2 of the License, or (at
e82789
# your option) any later version.
e82789
#
e82789
# This program is distributed in the hope that it will be useful, but
e82789
# WITHOUT ANY WARRANTY; without even the implied warranty of
e82789
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e82789
# General Public License for more details.
e82789
#
e82789
# You should have received a copy of the GNU General Public License
e82789
# along with this program; if not, write to the Free Software
e82789
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e82789
#
e82789
# ----------------------------------------------------------------------
e82789
# $Id$
e82789
# ----------------------------------------------------------------------
e82789
e82789
function help_getEntries {
e82789
e82789
    local DOCENTRY=''
e82789
e82789
    # Redefine positional parameters using ARGUMENTS. At this point,
e82789
    # option arguments have been removed from ARGUMENTS variable and
e82789
    # only non-option arguments remain in it. 
e82789
    eval set -- "$ARGUMENTS"
e82789
edaa9d
    if [[ $@ == '' ]];then
e82789
edaa9d
        # Define default documentation entry. This happen when
edaa9d
        # non-option arguments aren't provided to centos-art.sh
edaa9d
        # script.  Default documentation entry defined here points to
edaa9d
        # manual's main definition file, so only the manual's self
edaa9d
        # name and manual's directory name need to be defined here.
edaa9d
        MANUAL_SLFN[0]='tcar-ug'
edaa9d
        MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
e82789
edaa9d
    else
e82789
edaa9d
        # Retrive documentation entries passed to centos-art.sh script
edaa9d
        # as non-option arguments and store them in array variables in
edaa9d
        # order to describe their parts (e.g., manual name, chapter
edaa9d
        # name and section name) that way.  Documentation entries
edaa9d
        # passed as non-opiton arguments must have the
edaa9d
        # `MANUAL:CHAPTER:SECTION' format in order to be processed
edaa9d
        # correctly here. Empty spaces are not permitted. To separate
edaa9d
        # words, use the minus sign (e.g., hello-world) or cammel case
edaa9d
        # (e.g., HelloWorld).
edaa9d
        for DOCENTRY in $@;do
e82789
edaa9d
            # Manual self name.
edaa9d
            MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
edaa9d
                $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $1 }') -f \
edaa9d
                | tr '[:upper:]' '[:lower:]')
e82789
edaa9d
            # Manual self directory name.
edaa9d
            MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
edaa9d
                $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $1 }') -d )
edaa9d
edaa9d
            # Manual chapter name.
edaa9d
            MANUAL_CHAN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
edaa9d
                $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $2 }') -d )
edaa9d
edaa9d
            # Manual section name.
edaa9d
            MANUAL_SECN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
edaa9d
                $(echo "$DOCENTRY" | gawk 'BEGIN{ FS=":" } { print $3 }') -f )
edaa9d
edaa9d
            # Increment counting of non-option arguments.
edaa9d
            MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
e82789
edaa9d
        done
e82789
edaa9d
    fi
e82789
}