diff --git a/Automation/Scripts/tcar_printHelp.sh b/Automation/Scripts/tcar_printHelp.sh index a307ed8..b243ec7 100755 --- a/Automation/Scripts/tcar_printHelp.sh +++ b/Automation/Scripts/tcar_printHelp.sh @@ -27,15 +27,28 @@ function tcar_printHelp { - local TCAR_MANPAGE_FILE="${1}" - local TCAR_MANPAGE_NAME="${TCAR_MODULE_NAME}" + # Retrieve the man page name. This is the file name you want to retrieve + # documentation for. This value is optional. When it is not passed, the + # module name is used. + local TCAR_MANPAGE_NAME="${1:-${TCAR_MODULE_NAME}}" - if [[ -n ${TCAR_MANPAGE_FILE} ]];then - TCAR_MANPAGE_NAME="${TCAR_MODULE_NAME}-${TCAR_MANPAGE_FILE}" + # When the tcar_printHelp function is called from centos-art.sh file, the + # module name is set to an empty value so we assume you are retrieving + # documentation for centos-art.sh script itself. + if [[ -z ${TCAR_MANPAGE_NAME} ]];then + TCAR_MANPAGE_NAME=${TCAR_SCRIPT_NAME} fi - # Print documentation for manpage name. - /usr/bin/man -M ${TCAR_MODULE_DIR_MANUALS} "${TCAR_MANPAGE_NAME}" + # When the tcar_printHelp function is called from centos-art.sh file and + # an argument is passed to tcar_printHelp function, the argument comes + # here without stripping out the option's value so need to remove it here + # in order to request the correct information (that after the equal sign). + if [[ ${TCAR_MANPAGE_NAME} =~ '^--help' ]];then + TCAR_MANPAGE_NAME=$(echo ${TCAR_MANPAGE_NAME} | cut -d'=' -f2) + fi + + # Print requested documentation. + /usr/bin/man -M ${TCAR_SCRIPT_DIR_MANUALS}:${TCAR_MODULE_DIR_MANUALS} "${TCAR_MANPAGE_NAME}" # Finish script execution successfully. exit 0 diff --git a/Automation/centos-art.conf.sh b/Automation/centos-art.conf.sh index fd1bfde..24cb843 100755 --- a/Automation/centos-art.conf.sh +++ b/Automation/centos-art.conf.sh @@ -90,16 +90,7 @@ declare -xr TEXTDOMAINDIR=${TCAR_SCRIPT_BASEDIR}/Locales # Set absolute path to documentation search path. This is the location # where final documentation formats (e.g., man pages) will be saved # in. -declare -x TCAR_MANUAL_SEARCHPATH=${TCAR_SCRIPT_BASEDIR}/Manuals - -# Set absolute path to documentation source format. This is the file -# we'll use as input to `a2x' command to produce documentation in -# different formats. -declare -x TCAR_MANUAL_FILE=${TCAR_MANUAL_SEARCHPATH}/${TCAR_SCRIPT_NAME}.asciidoc - -# Set command used to read man pages. Include in this command the -# sarch path where final man pages live in. -declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" +declare -x TCAR_SCRIPT_DIR_MANUALS=${TCAR_SCRIPT_BASEDIR}/Manuals ###################################################################### # User-related configuration variables. diff --git a/Automation/centos-art.sh b/Automation/centos-art.sh index 2e4263f..db6f16b 100755 --- a/Automation/centos-art.sh +++ b/Automation/centos-art.sh @@ -107,58 +107,71 @@ while true; do case "${1}" in - -h | --he | --hel | --help ) - # Print centos-art.sh script's help. - if [[ -z ${TCAR_MODULE_NAME} ]];then - ${TCAR_MANUAL_READER} ${TCAR_SCRIPT_NAME} - exit 0 - else - TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" + --help* ) + + if [[ -z ${TCAR_MODULE_NAME} ]];then + # Print centos-art.sh script's help. Consider that the + # --help option can receive an argument by using the + # equal sign (e.g., + # --help=tcar_setModuleEnvironment.sh). However, it + # is not possible to use spaces instead of equal sign + # because that would confuse other options from being + # parsed. + tcar_printHelp "${1}" + exit 0 + else + # Store the argument for further processing inside the + # module environment that will be executed later. + TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" + shift 1 + fi + ;; + + --version ) + + # Print centos-art.sh script's version. + if [[ -z ${TCAR_MODULE_NAME} ]];then + tcar_printVersion + exit 0 + else + TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" + shift 1 + fi + ;; + + --quiet ) + + TCAR_FLAG_QUIET='true' shift 1 - fi - ;; + ;; - -v | --ve | --ver | --vers | --versi | --versio | --version ) - # Print centos-art.sh script's version. - if [[ -z ${TCAR_MODULE_NAME} ]];then - tcar_printVersion - exit 0 - else - TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" + --yes ) + + TCAR_FLAG_YES='true' shift 1 - fi - ;; + ;; - -q | --qu | --qui | --quie | --quiet ) - TCAR_FLAG_QUIET='true' - shift 1 - ;; + --debug ) - -y | --ye | --yes ) - TCAR_FLAG_YES='true' - shift 1 - ;; + TCAR_FLAG_DEBUG='true' + shift 1 + ;; - -d | --de | --deb | --debu | --debug ) - TCAR_FLAG_DEBUG='true' - shift 1 - ;; - - * ) - # Store module-specific option arguments. This is, all - # arguments not considered part of centos-art.sh script - # itself. The module-specific option arguments are passed, - # later, to getopt for option processing, inside the - # module-specific environments. - TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" - shift 1 - if [[ $# -gt 0 ]];then - continue - else - break - fi - ;; + * ) + # Store module-specific option arguments. This is, all + # arguments not considered part of centos-art.sh script + # itself. The module-specific option arguments are passed, + # later, to getopt for option processing, inside the + # module-specific environments. + TCAR_MODULE_ARGUMENT="-g ${1} ${TCAR_MODULE_ARGUMENT}" + shift 1 + if [[ $# -gt 0 ]];then + continue + else + break + fi + ;; esac done