|
|
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 |
#
|
|
|
2fe9b7 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
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 |
|
|
|
e9a725 |
# Initialize manual's documentation entry as an empty value local
|
|
|
e9a725 |
# to this function.
|
|
|
e9a725 |
local MANUAL_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 |
|
|
|
e9a725 |
# Define default documentation entry. This happens 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.
|
|
|
ccf995 |
MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]='tcar-fs'
|
|
|
ccf995 |
MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]='Tcar-fs'
|
|
|
edaa9d |
MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
|
|
|
e82789 |
|
|
|
edaa9d |
else
|
|
|
e82789 |
|
|
|
523e52 |
# Retrive documentation entries passed to `centos-art.sh'
|
|
|
523e52 |
# script as non-option arguments and store them in array
|
|
|
523e52 |
# variables in order to describe their parts (e.g., manual
|
|
|
523e52 |
# name, chapter name and section name) that way.
|
|
|
523e52 |
# Documentation entries passed as non-opiton arguments must be
|
|
|
e0c375 |
# written either in `MANUAL:PART:CHAPTER:SECTION' or
|
|
|
e0c375 |
# `path/to/dir' formats in order to be processed correctly
|
|
|
e0c375 |
# here. Empty spaces are not permitted. To separate words, use
|
|
|
e0c375 |
# the minus sign (e.g., hello-world) or cammel case (e.g.,
|
|
|
e0c375 |
# HelloWorld).
|
|
|
e9a725 |
for MANUAL_DOCENTRY in $@;do
|
|
|
e82789 |
|
|
|
e9a725 |
if [[ ${MANUAL_DOCENTRY} =~ '^([A-Za-z0-9-]+)(:[A-Za-z0-9-]*){0,3}$' ]];then
|
|
|
e82789 |
|
|
|
e0c375 |
# When `MANUAL:PART:CHAPTER:SECTION' is used as format
|
|
|
e0c375 |
# to documentation entry, you can specify the manual,
|
|
|
aee706 |
# chapter and section where documentation actions will
|
|
|
aee706 |
# take place on.
|
|
|
edaa9d |
|
|
|
aee706 |
# Manual self name.
|
|
|
aee706 |
MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $1 }') -f \
|
|
|
aee706 |
| tr '[:upper:]' '[:lower:]')
|
|
|
edaa9d |
|
|
|
aee706 |
# Manual self directory name.
|
|
|
aee706 |
MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $1 }') -d )
|
|
|
aee706 |
|
|
|
e0c375 |
# Manual part name.
|
|
|
e0c375 |
MANUAL_PART[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $2 }') -d )
|
|
|
aee706 |
|
|
|
e0c375 |
# Manual chapter name.
|
|
|
e0c375 |
MANUAL_CHAP[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $3 }') -d )
|
|
|
e0c375 |
|
|
|
aee706 |
# Manual section name.
|
|
|
e0c375 |
MANUAL_SECT[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN{ FS=":" } { print $4 }') -f )
|
|
|
aee706 |
|
|
|
e9a725 |
elif [[ ${MANUAL_DOCENTRY} =~ '^(trunk|branches|tags)' ]];then
|
|
|
aee706 |
|
|
|
aee706 |
# When `path/to/dir' is used as format to
|
|
|
aee706 |
# documentation entry, you cannot specify the manual
|
|
|
aee706 |
# chapter or section where documentation actions will
|
|
|
aee706 |
# take place on. Instead, they are predefined for you
|
|
|
aee706 |
# here. Use this format to document directories inside
|
|
|
aee706 |
# your working copy.
|
|
|
aee706 |
|
|
|
e9a725 |
# Manual's self name.
|
|
|
aee706 |
MANUAL_SLFN[${MANUAL_DOCENTRY_COUNT}]='tcar-fs'
|
|
|
aee706 |
|
|
|
e9a725 |
# Manual's self directory name.
|
|
|
aee706 |
MANUAL_DIRN[${MANUAL_DOCENTRY_COUNT}]='Tcar-fs'
|
|
|
aee706 |
|
|
|
e9a725 |
# Manual's chapter name.
|
|
|
e0c375 |
MANUAL_CHAP[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN { FS="/" }; { if ( NF >= 1 ) print $1 }' ) -d )
|
|
|
aee706 |
|
|
|
e9a725 |
# Manual's section name.
|
|
|
e0c375 |
MANUAL_SECT[${MANUAL_DOCENTRY_COUNT}]=$(cli_getRepoName \
|
|
|
e9a725 |
$(echo "${MANUAL_DOCENTRY}" | gawk 'BEGIN { FS="/" }; { if ( NF >= 2 ) print $0 }' \
|
|
|
5158b4 |
| cut -d/ -f2- | tr '/' '-') -f )
|
|
|
aee706 |
|
|
|
aee706 |
else
|
|
|
aee706 |
cli_printMessage "`gettext "The documentation entry provided isn't supported."`" --as-error-line
|
|
|
aee706 |
fi
|
|
|
edaa9d |
|
|
|
edaa9d |
# Increment counting of non-option arguments.
|
|
|
edaa9d |
MANUAL_DOCENTRY_COUNT=$(($MANUAL_DOCENTRY_COUNT + 1))
|
|
|
e82789 |
|
|
|
edaa9d |
done
|
|
|
e82789 |
|
|
|
edaa9d |
fi
|
|
|
523e52 |
|
|
|
e82789 |
}
|