]> git.street.me.uk Git - andy/dehydrated.git/commitdiff
rewritten help method to get rid of `column` dependency
authorLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 18:13:50 +0000 (19:13 +0100)
committerLukas Schauer <lukas@schauer.so>
Fri, 8 Jan 2016 18:13:50 +0000 (19:13 +0100)
letsencrypt.sh

index 6364d26f6feb72c8885ba18851add5166aadbc47..8d9fbd864a206d820ea3abdbc2a59422dbca3c9c 100755 (executable)
@@ -502,29 +502,22 @@ command_revoke() {
 # Usage: --help (-h)
 # Description: Show help text
 command_help() {
-  echo "Usage: ${0} [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ..."
-  echo
-  echo "Default command: help"
-  echo
-  (
+  printf "Usage: %s [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ...\n\n" "${0}"
+  printf "Default command: help\n\n"
   echo "Commands:"
   grep -e '^[[:space:]]*# Usage:' -e '^[[:space:]]*# Description:' -e '^command_.*()[[:space:]]*{' "${0}" | while read -r usage; read -r description; read -r command; do
     if [[ ! "${usage}" =~ Usage ]] || [[ ! "${description}" =~ Description ]] || [[ ! "${command}" =~ ^command_ ]]; then
-      echo "Error generating help text." >&2
-      exit 1
+      _exiterr "Error generating help text."
     fi
-    printf " %s\t%s\n" "${usage##"# Usage: "}" "${description##"# Description: "}"
+    printf " %-32s %s\n" "${usage##"# Usage: "}" "${description##"# Description: "}"
   done
-  echo "---"
-  echo "Parameters:"
+  printf -- "\nParameters:\n"
   grep -E -e '^[[:space:]]*# PARAM_Usage:' -e '^[[:space:]]*# PARAM_Description:' "${0}" | while read -r usage; read -r description; do
     if [[ ! "${usage}" =~ Usage ]] || [[ ! "${description}" =~ Description ]]; then
-      echo "Error generating help text." >&2
-      exit 1
+      _exiterr "Error generating help text."
     fi
-    printf " %s\t%s\n" "${usage##"# PARAM_Usage: "}" "${description##"# PARAM_Description: "}"
+    printf " %-32s %s\n" "${usage##"# PARAM_Usage: "}" "${description##"# PARAM_Description: "}"
   done
-  ) | column -t -s $'\t' | sed 's/^---$//g'
 }
 
 # Usage: --env (-e)