]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Fixing scripts/get-module-version
authorFrank Brehm <frank@brehm-online.com>
Tue, 23 May 2023 14:24:12 +0000 (16:24 +0200)
committerFrank Brehm <frank@brehm-online.com>
Tue, 23 May 2023 14:24:12 +0000 (16:24 +0200)
scripts/functions.rc
scripts/get-module-version

index daf6ab2034aeec5f4084517cbb80b9857330a7b3..e4e753f252f2eea6374d3a2bea4092c0d9f302ba 100644 (file)
@@ -8,7 +8,7 @@ BLUE=""
 CYAN=""
 NORMAL=""
 
-VERSION="0.3.1"
+VERSION="0.3.2"
 
 # shellcheck disable=SC2034
 STD_SHORT_OPTIONS="sqdvhV"
index daf9e7355b27561cd052332f8ff6b4d2da41b9f5..07df467e71b412dd76e5240e99b7adef2eed5724 100755 (executable)
@@ -20,6 +20,8 @@ PUPPET_ENV='*'
 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.
 
@@ -34,7 +36,7 @@ usage() {
               ${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:
@@ -85,20 +87,20 @@ get_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
@@ -106,13 +108,6 @@ get_options() {
         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
@@ -122,6 +117,8 @@ get_options() {
 
     if [[ ! -d "${ENV_DIR}" ]] ; then
         error "Puppet environments directory '${RED}${ENV_DIR}${NORMAL}' does not exists."
+        echo >&2
+        usage >&2
         exit 5
     fi