fix(cli): theme-aware semantic glyphs

Keep section headers, check skips, and layout separators aligned with the active glyph theme.

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-02 12:31:44 +00:00
parent 11ac2c62c6
commit 81be3b701e
6 changed files with 54 additions and 4 deletions

View file

@ -38,7 +38,7 @@ func (c *CheckBuilder) Fail() *CheckBuilder {
func (c *CheckBuilder) Skip() *CheckBuilder {
c.status = "skipped"
c.style = DimStyle
c.icon = "-"
c.icon = Glyph(":skip:")
return c
}

View file

@ -29,6 +29,9 @@ func TestCheckBuilder(t *testing.T) {
if got == "" {
t.Error("Empty output for Skip")
}
if !strings.Contains(got, "[SKIP]") {
t.Error("Expected ASCII skip icon")
}
// Warn
c = Check("foo").Warn()

View file

@ -147,7 +147,8 @@ func Task(label, message string) {
//
// cli.Section("audit") // ── AUDIT ──
func Section(name string) {
header := "── " + strings.ToUpper(compileGlyphs(name)) + " ──"
dash := Glyph(":dash:")
header := dash + dash + " " + strings.ToUpper(compileGlyphs(name)) + " " + dash + dash
fmt.Println(AccentStyle.Render(header))
}

View file

@ -125,3 +125,19 @@ func TestSemanticOutput_GlyphShortcodes(t *testing.T) {
t.Fatalf("expected progress item shortcode to be rendered, got %q", out)
}
}
func TestSection_GlyphTheme(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
out := captureOutput(func() {
Section("audit")
})
if !strings.Contains(out, "-- AUDIT --") {
t.Fatalf("expected ASCII section header, got %q", out)
}
if strings.Contains(out, "── AUDIT ──") {
t.Fatalf("expected glyph theme to avoid unicode dashes, got %q", out)
}
}

View file

@ -66,9 +66,9 @@ func (c *Composite) renderSeparator(sb *strings.Builder, depth int) {
indent := strings.Repeat(" ", depth)
switch currentRenderStyle {
case RenderBoxed:
sb.WriteString(indent + "├" + strings.Repeat("─", 40) + "┤\n")
sb.WriteString(indent + Glyph(":tee:") + strings.Repeat(Glyph(":dash:"), 40) + Glyph(":tee:") + "\n")
case RenderSimple:
sb.WriteString(indent + strings.Repeat("─", 40) + "\n")
sb.WriteString(indent + strings.Repeat(Glyph(":dash:"), 40) + "\n")
}
}

30
pkg/cli/render_test.go Normal file
View file

@ -0,0 +1,30 @@
package cli
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCompositeRender_GlyphTheme(t *testing.T) {
prevStyle := currentRenderStyle
t.Cleanup(func() {
currentRenderStyle = prevStyle
})
restoreThemeAndColors(t)
UseASCII()
c := Layout("HCF")
c.H("header").C("content").F("footer")
UseRenderSimple()
out := c.String()
assert.Contains(t, out, strings.Repeat("-", 40))
UseRenderBoxed()
out = c.String()
assert.Contains(t, out, "+")
assert.Contains(t, out, strings.Repeat("-", 40))
}