Blame Scripts/Bash/Functions/Help/help_getEntries.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# help_getEntries.sh -- This function interpretes non-option
878a2b
# arguments passed to `help' functionality through the command-line
878a2b
# and redefines array variables related to documentation entries.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function help_getEntries {
878a2b
878a2b
    # Initialize manual's documentation entry as an empty value local
878a2b
    # to this function.
878a2b
    local MANUAL_DOCENTRY=''
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS. At this point,
878a2b
    # option arguments have been removed from ARGUMENTS variable and
878a2b
    # only non-option arguments remain in it. 
878a2b
    eval set -- "$ARGUMENTS"
878a2b
654704
    # Retrive documentation entries passed to `centos-art.sh' script
654704
    # as non-option arguments and store them in array variables in
654704
    # order to describe their parts (e.g., manual name, chapter name
654704
    # and section name) that way.  Documentation entries passed as
654704
    # non-opiton arguments must be written either in
654704
    # `MANUAL:PART:CHAPTER:SECTION' or `path/to/dir' formats in order
654704
    # to be processed correctly here. Empty spaces are not permitted.
654704
    # To separate words, use the minus sign (e.g., hello-world) or
654704
    # cammel case (e.g., HelloWorld).
654704
    for MANUAL_DOCENTRY in $@;do
878a2b
654704
        if [[ ${MANUAL_DOCENTRY} =~ '^[[:alpha:]][[:alnum:]-]+:([[:alnum:]-]*:){2}[[:alnum:]/]*' ]];then
878a2b
654704
            # When `MANUAL:PART:CHAPTER:SECTION' is used as format to
654704
            # documentation entry, you can specify the manual, chapter
654704
            # and section where documentation actions will take place
654704
            # on.
878a2b
654704
            # Manual self name.
654704
            MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $1 }') -f \
654704
                | tr '[:upper:]' '[:lower:]')
878a2b
654704
            # Manual self directory name.
654704
            MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $1 }') -d )
878a2b
654704
            # Manual part name.
654704
            MANUAL_PART[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $2 }') -d )
878a2b
654704
            # Manual chapter name.
654704
            MANUAL_CHAP[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $3 }') -d )
878a2b
654704
            # Manual section name.
654704
            MANUAL_SECT[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $4 }') -f )
878a2b
654704
        elif [[ ${MANUAL_DOCENTRY} =~ '^(trunk|branches|tags)' ]];then
878a2b
654704
            # When `path/to/dir' is used as format to documentation
654704
            # entry, you cannot specify the manual chapter or section
654704
            # where documentation actions will take place on. Instead,
654704
            # they are predefined for you here. Use this format to
654704
            # document directories inside your working copy.
878a2b
654704
            # Manual's self name.
654704
            MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]='tcar-fs'
878a2b
654704
            # Manual's self directory name.
654704
            MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]='Tcar-fs'
878a2b
654704
            # Manual's chapter name.
654704
            MANUAL_CHAP[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN { FS="/" }; { if ( NF >= 1 ) print $1 }' ) -d )
878a2b
654704
            # Manual's section name.
654704
            MANUAL_SECT[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
654704
                $(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN { FS="/" }; { if ( NF >= 2 ) print $0 }' \
654704
                | cut -d/ -f2- | tr '/' '-') -f )
878a2b
654704
        else
878a2b
654704
            cli_printMessage "`gettext "The documentation entry provided isn't supported."`" --as-error-line
878a2b
654704
        fi
878a2b
654704
        # Increment counting of non-option arguments.
654704
        MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
878a2b
654704
    done
878a2b
878a2b
}