mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-04-20 23:41:21 +02:00
rewritten help method to get rid of column dependency
This commit is contained in:
@@ -502,29 +502,22 @@ command_revoke() {
|
|||||||
# Usage: --help (-h)
|
# Usage: --help (-h)
|
||||||
# Description: Show help text
|
# Description: Show help text
|
||||||
command_help() {
|
command_help() {
|
||||||
echo "Usage: ${0} [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ..."
|
printf "Usage: %s [-h] [command [argument]] [parameter [argument]] [parameter [argument]] ...\n\n" "${0}"
|
||||||
echo
|
printf "Default command: help\n\n"
|
||||||
echo "Default command: help"
|
|
||||||
echo
|
|
||||||
(
|
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
grep -e '^[[:space:]]*# Usage:' -e '^[[:space:]]*# Description:' -e '^command_.*()[[:space:]]*{' "${0}" | while read -r usage; read -r description; read -r command; do
|
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
|
if [[ ! "${usage}" =~ Usage ]] || [[ ! "${description}" =~ Description ]] || [[ ! "${command}" =~ ^command_ ]]; then
|
||||||
echo "Error generating help text." >&2
|
_exiterr "Error generating help text."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
printf " %s\t%s\n" "${usage##"# Usage: "}" "${description##"# Description: "}"
|
printf " %-32s %s\n" "${usage##"# Usage: "}" "${description##"# Description: "}"
|
||||||
done
|
done
|
||||||
echo "---"
|
printf -- "\nParameters:\n"
|
||||||
echo "Parameters:"
|
|
||||||
grep -E -e '^[[:space:]]*# PARAM_Usage:' -e '^[[:space:]]*# PARAM_Description:' "${0}" | while read -r usage; read -r description; do
|
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
|
if [[ ! "${usage}" =~ Usage ]] || [[ ! "${description}" =~ Description ]]; then
|
||||||
echo "Error generating help text." >&2
|
_exiterr "Error generating help text."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
printf " %s\t%s\n" "${usage##"# PARAM_Usage: "}" "${description##"# PARAM_Description: "}"
|
printf " %-32s %s\n" "${usage##"# PARAM_Usage: "}" "${description##"# PARAM_Description: "}"
|
||||||
done
|
done
|
||||||
) | column -t -s $'\t' | sed 's/^---$//g'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: --env (-e)
|
# Usage: --env (-e)
|
||||||
|
|||||||
Reference in New Issue
Block a user