From: Lukas Schauer Date: Fri, 8 Jan 2016 18:13:50 +0000 (+0100) Subject: rewritten help method to get rid of `column` dependency X-Git-Tag: v0.1.0~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7727f5ea61d7993793517d4fcb72a1bde609eef2;p=thirdparty%2Fdehydrated.git rewritten help method to get rid of `column` dependency --- diff --git a/letsencrypt.sh b/letsencrypt.sh index 6364d26..8d9fbd8 100755 --- a/letsencrypt.sh +++ b/letsencrypt.sh @@ -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)