Info: Further reduce size of info()

This commit is contained in:
Dylan Araps 2016-12-14 21:33:05 +11:00
parent bdcb0955c4
commit 5ff2a7d9dc
1 changed files with 21 additions and 25 deletions

View File

@ -2432,34 +2432,30 @@ info() {
output="${2:-$1}" output="${2:-$1}"
output="$(trim "${!output}")" output="$(trim "${!output}")"
# If the output is empty, don't print anything.
[[ -z "${output// }" ]] && \
{ err "Info: Couldn't detect ${1}."; return; }
case "$1" in
"title")
string="${title_color}${bold}${output}"
string="${string/@/${at_color}@${title_color}${bold}}"
length="${#output}"
prin "$string"
;;
"underline")
string="${underline_color}${output}"
prin "$string"
;;
*)
if [[ "$2" && "${output// }" ]]; then if [[ "$2" && "${output// }" ]]; then
length="$((${#1} + ${#output} + 2))" length="$((${#1} + ${#output} + 2))"
prin "$1" "$output" prin "$1" "$output"
elif [[ "${output// }" ]]; then elif [[ "${output// }" ]]; then
length="${#output}" case "$1" in
prin "$output" "title")
fi string="${title_color}${bold}${output}"
string="${string/@/${at_color}@${title_color}${bold}}"
;; ;;
"underline")
string="${underline_color}${output}"
;;
*) string="$output" ;;
esac esac
length="${#output}"
prin "$string"
else
err "Info: Couldn't detect ${1}."
fi
} }
prin() { prin() {
@ -2470,8 +2466,8 @@ prin() {
[[ -z "$2" ]] && local subtitle_color="$info_color" [[ -z "$2" ]] && local subtitle_color="$info_color"
# Format the output # Format the output
string="$(trim "$string")"
string="${subtitle}${string}" string="${subtitle}${string}"
string="$(trim "$string")"
string="${string/:/${reset}${colon_color}:${info_color}}" string="${string/:/${reset}${colon_color}:${info_color}}"
string="${subtitle_color}${bold}${string}" string="${subtitle_color}${bold}${string}"