release 1.14.0: colour-distinct SUMMARY boxes per severity
Terminal SUMMARY uses verdict-tinted header, bold counts, and per-row background tints for OK/ERROR/WARN/INFO/BLOCK. HTML mon pages map those lines to sum-* CSS panels with matching emphasis.
This commit is contained in:
parent
31565f46d1
commit
8f3d221e02
4 changed files with 153 additions and 43 deletions
102
lib.sh
102
lib.sh
|
|
@ -894,56 +894,94 @@ section() {
|
|||
}
|
||||
|
||||
# Print SUMMARY totals box for given counts (phase-local or global).
|
||||
# Each severity row is colour-distinct: badge + full-line bg tint + bold count (v1.14.0).
|
||||
# $1=pass $2=fail $3=warn $4=info $5=block
|
||||
_summary_totals_box() {
|
||||
local pass_n="$1" fail_n="$2" warn_n="$3" info_n="$4" blk_n="$5"
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- '\n%s┌ %s ┐%s\n' "$BG_SEC" "$(i18n_tag SUMMARY)" "$N"
|
||||
_sum_badge() { # $1=bg $2=tag $3=fg $4=n
|
||||
local _tg
|
||||
_tg=$(i18n_tag "$2")
|
||||
printf -- ' %s┌ %-5s┐%s %s%4d%s\n' "$1" "$_tg" "$N" "$3" "$4" "$N"
|
||||
}
|
||||
_sum_badge "$BG_OK" "OK" "$G" "$pass_n"
|
||||
[ "$fail_n" -gt 0 ] && _sum_badge "$BG_ERR" "ERROR" "$R" "$fail_n"
|
||||
[ "$warn_n" -gt 0 ] && _sum_badge "$BG_WARN" "WARN" "$Y" "$warn_n"
|
||||
[ "$info_n" -gt 0 ] && _sum_badge "$BG_INFO" "INFO" "$C" "$info_n"
|
||||
[ "$blk_n" -gt 0 ] && _sum_badge "$BG_BLK" "BLOCK" "$M" "$blk_n"
|
||||
local hdr_bg hdr_fg _sum_lbl
|
||||
_sum_lbl=$(i18n_tag SUMMARY)
|
||||
# Header colour follows overall verdict
|
||||
if [ "$fail_n" -gt 0 ] || [ "$blk_n" -gt 0 ]; then
|
||||
hdr_bg="${BG_ERR}"
|
||||
hdr_fg="${R}"
|
||||
elif [ "$warn_n" -gt 0 ]; then
|
||||
hdr_bg="${BG_WARN}"
|
||||
hdr_fg="${Y}"
|
||||
else
|
||||
printf -- '\n[ %s ]\n' "$(i18n_tag SUMMARY)"
|
||||
printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag OK)" "$G" "$pass_n" "$N"
|
||||
[ "$fail_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag ERROR)" "$R" "$fail_n" "$N"
|
||||
[ "$warn_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag WARN)" "$Y" "$warn_n" "$N"
|
||||
[ "$info_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag INFO)" "$C" "$info_n" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag BLOCK)" "$M" "$blk_n" "$N"
|
||||
hdr_bg="${BG_OK}"
|
||||
hdr_fg="${G}"
|
||||
fi
|
||||
# one-line rollup (bold label, severity-coloured counts)
|
||||
printf -- ' %stotals:%s %s%d OK%s' "$B" "$N" "$G" "$pass_n" "$N"
|
||||
[ "$fail_n" -gt 0 ] && printf -- ' · %s%d ERROR%s' "$R" "$fail_n" "$N"
|
||||
[ "$warn_n" -gt 0 ] && printf -- ' · %s%d WARN%s' "$Y" "$warn_n" "$N"
|
||||
[ "$info_n" -gt 0 ] && printf -- ' · %s%d INFO%s' "$C" "$info_n" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' · %s%d BLOCKER%s' "$M" "$blk_n" "$N"
|
||||
printf '\n'
|
||||
# overall verdict
|
||||
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
# Dim full-line tints (bold fg on soft bg) — distinct per severity
|
||||
local ROW_OK=$'\e[1;32;48;5;22m' # bold green on dark green
|
||||
local ROW_ERR=$'\e[1;97;48;5;52m' # bold white on dark red
|
||||
local ROW_WARN=$'\e[1;30;48;5;178m' # bold black on gold
|
||||
local ROW_INFO=$'\e[1;97;48;5;24m' # bold white on dark blue
|
||||
local ROW_BLK=$'\e[1;97;48;5;53m' # bold white on dark magenta
|
||||
local ROW_TOT=$'\e[1;37;48;5;236m' # bold white on dark gray
|
||||
|
||||
printf -- '\n%s╔══════════════════════════════════════╗%s\n' "$hdr_bg" "$N"
|
||||
printf -- '%s║ %-34s ║%s\n' "$hdr_bg" "$_sum_lbl" "$N"
|
||||
printf -- '%s╚══════════════════════════════════════╝%s\n' "$hdr_bg" "$N"
|
||||
|
||||
# $1=row_bg $2=badge_bg $3=tag $4=n $5=label_fg — full-width-ish row
|
||||
_sum_row() {
|
||||
local row_bg="$1" badge="$2" tag="$3" n="$4" fg="$5" _tg pad
|
||||
_tg=$(i18n_tag "$tag")
|
||||
pad=$(printf '%-5s' "$_tg")
|
||||
printf -- ' %s┌ %s┐%s %s %s%6d%s %s%-12s%s\n' \
|
||||
"$badge" "$pad" "$N" \
|
||||
"$row_bg" "$B" "$n" "$N" \
|
||||
"$fg$B" "$_tg" "$N"
|
||||
}
|
||||
_sum_row "$ROW_OK" "$BG_OK" "OK" "$pass_n" "$G"
|
||||
[ "$fail_n" -gt 0 ] && _sum_row "$ROW_ERR" "$BG_ERR" "ERROR" "$fail_n" "$R"
|
||||
[ "$warn_n" -gt 0 ] && _sum_row "$ROW_WARN" "$BG_WARN" "WARN" "$warn_n" "$Y"
|
||||
[ "$info_n" -gt 0 ] && _sum_row "$ROW_INFO" "$BG_INFO" "INFO" "$info_n" "$C"
|
||||
[ "$blk_n" -gt 0 ] && _sum_row "$ROW_BLK" "$BG_BLK" "BLOCK" "$blk_n" "$M"
|
||||
|
||||
# totals rollup on tinted bar
|
||||
printf -- ' %s %s totals: %s%d OK%s' "$ROW_TOT" "$B" "$G$B" "$pass_n" "$N$ROW_TOT"
|
||||
[ "$fail_n" -gt 0 ] && printf -- ' %s·%s %s%d ERROR%s' "$D" "$N$ROW_TOT" "$R$B" "$fail_n" "$N$ROW_TOT"
|
||||
[ "$warn_n" -gt 0 ] && printf -- ' %s·%s %s%d WARN%s' "$D" "$N$ROW_TOT" "$Y$B" "$warn_n" "$N$ROW_TOT"
|
||||
[ "$info_n" -gt 0 ] && printf -- ' %s·%s %s%d INFO%s' "$D" "$N$ROW_TOT" "$C$B" "$info_n" "$N$ROW_TOT"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' %s·%s %s%d BLOCKER%s' "$D" "$N$ROW_TOT" "$M$B" "$blk_n" "$N$ROW_TOT"
|
||||
printf -- ' %s\n' "$N"
|
||||
else
|
||||
printf -- '\n[ %s ]\n' "$_sum_lbl"
|
||||
printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag OK)" "$G$B" "$pass_n" "$N"
|
||||
[ "$fail_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag ERROR)" "$R$B" "$fail_n" "$N"
|
||||
[ "$warn_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag WARN)" "$Y$B" "$warn_n" "$N"
|
||||
[ "$info_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag INFO)" "$C$B" "$info_n" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' [ %-5s ] %s%4d%s\n' "$(i18n_tag BLOCK)" "$M$B" "$blk_n" "$N"
|
||||
printf -- ' %stotals:%s %s%d OK%s' "$B" "$N" "$G$B" "$pass_n" "$N"
|
||||
[ "$fail_n" -gt 0 ] && printf -- ' · %s%d ERROR%s' "$R$B" "$fail_n" "$N"
|
||||
[ "$warn_n" -gt 0 ] && printf -- ' · %s%d WARN%s' "$Y$B" "$warn_n" "$N"
|
||||
[ "$info_n" -gt 0 ] && printf -- ' · %s%d INFO%s' "$C$B" "$info_n" "$N"
|
||||
[ "$blk_n" -gt 0 ] && printf -- ' · %s%d BLOCKER%s' "$M$B" "$blk_n" "$N"
|
||||
printf '\n'
|
||||
fi
|
||||
# overall verdict — bold label, filled badge
|
||||
if [ "$fail_n" -eq 0 ] && [ "$blk_n" -eq 0 ] && [ "$warn_n" -eq 0 ]; then
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- ' %s┌ OK ┐%s %sall clear%s\n' "$BG_OK" "$N" "$G" "$N"
|
||||
printf -- ' %s┌ OK ┐%s %s%sall clear%s\n' "$BG_OK" "$N" "$G" "$B" "$N"
|
||||
else
|
||||
printf -- ' %s[ OK ] all clear%s\n' "$G" "$N"
|
||||
printf -- ' %s[ OK ] %sall clear%s\n' "$G" "$B" "$N"
|
||||
fi
|
||||
elif [ "$fail_n" -eq 0 ] && [ "$blk_n" -eq 0 ]; then
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- ' %s┌ WARN ┐%s %swarnings only (no hard fail)%s\n' "$BG_WARN" "$N" "$Y" "$N"
|
||||
printf -- ' %s┌ WARN ┐%s %s%swarnings only (no hard fail)%s\n' "$BG_WARN" "$N" "$Y" "$B" "$N"
|
||||
else
|
||||
printf -- ' %s[ WARN ] warnings only (no hard fail)%s\n' "$Y" "$N"
|
||||
printf -- ' %s[ WARN ] %swarnings only (no hard fail)%s\n' "$Y" "$B" "$N"
|
||||
fi
|
||||
else
|
||||
local _fail_msg
|
||||
_fail_msg=$(i18n_text 'failed — see list above')
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf -- ' %s┌ ERROR ┐%s %s%s%s\n' "$BG_ERR" "$N" "$R" "$_fail_msg" "$N"
|
||||
printf -- ' %s┌ ERROR ┐%s %s%s%s%s\n' "$BG_ERR" "$N" "$R" "$B" "$_fail_msg" "$N"
|
||||
else
|
||||
printf -- ' %s[ ERROR ] %s%s\n' "$R" "$_fail_msg" "$N"
|
||||
printf -- ' %s[ ERROR ] %s%s%s\n' "$R" "$B" "$_fail_msg" "$N"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue