DEFAULT_ENV_DIR="/etc/puppetlabs/code/environments"
ENV_DIR="${DEFAULT_ENV_DIR}"
+detect_color
+
DESCRIPTION=$( cat <<-EOF
Retrieving version number of given Puppet module(s) in all environments.
${BASE_NAME} [-V|--version]
Mandatory Parameter(s):
- MODULE: The short name of the module(s) (without vendor), for which the
+ MODULE: The short name of the module(s) (without vendor), for which the
current used version should be shown.
Options:
while [[ "$i" -lt "${len}" ]] ; do
arg="${REMAINING_OPTS[$i]}"
- debug "Evaluating option '${CYAN}${arg}${NORMAL}' ..."
+ # debug "Evaluating option '${CYAN}${arg}${NORMAL}' ..."
case "${arg}" in
-E|--env|--environment)
j=$(( $i + 1 ))
PUPPET_ENV="${REMAINING_OPTS[$j]}"
- debug "Puppet environment is now: '${CYAN}${PUPPET_ENV}${NORMAL}', i = $i."
i=$(( $i + 2 ))
+ # debug "Puppet environment is now: '${CYAN}${PUPPET_ENV}${NORMAL}', i = $i."
;;
-D|--dir)
j=$(( $i + 1 ))
ENV_DIR="${REMAINING_OPTS[$j]}"
- debug "Puppet environment directory is now: '${CYAN}${ENV_DIR}${NORMAL}', i = $i."
i=$(( $i + 2 ))
+ # debug "Puppet environment directory is now: '${CYAN}${ENV_DIR}${NORMAL}', i = $i."
;;
*) echo -e "Internal error - option '${RED}${arg}${NORMAL}' was wrong!"
exit 1
esac
done
- if [[ "${#REMAINING_OPTS[@]}" -gt 0 ]] ; then
- error "Unknown options: ${REMAINING_OPTS[*]}"
- echo >&2
- usage >&2
- exit 2
- fi
-
if [[ "${#REMAINING_ARGS[@]}" == "0" ]] ; then
error "No module name to search for the version given."
echo >&2
if [[ ! -d "${ENV_DIR}" ]] ; then
error "Puppet environments directory '${RED}${ENV_DIR}${NORMAL}' does not exists."
+ echo >&2
+ usage >&2
exit 5
fi