Merge feature/banner-bold-newline
All checks were successful
check / check (push) Successful in 1m55s

This commit is contained in:
2026-06-17 05:52:03 +02:00
3 changed files with 18 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ func setupGlobals(lc fx.Lifecycle, g *globals.Globals, v *vaultik.Vaultik, opts
g.ShortCommit(), g.CommitDate,
g.StartTime.Format(time.RFC3339))
v.UI.Banner("%s", globals.Homepage)
v.UI.Banner("")
}
return nil
},

View File

@@ -153,10 +153,14 @@ func (w *Writer) Progress(format string, args ...any) {
w.emit(ansiWhite, " "+Marker, "", format, args)
}
// Banner prints a line with no marker, left-aligned. Used for the
// application startup banner only.
// Banner prints a line with no marker, left-aligned. Bold when color
// is enabled. Used for the application startup banner only.
func (w *Writer) Banner(format string, args ...any) {
_, _ = fmt.Fprintln(w.out, fmt.Sprintf(format, args...))
body := fmt.Sprintf(format, args...)
if w.color {
body = ansiBold + body + ansiReset
}
_, _ = fmt.Fprintln(w.out, body)
}
// emit writes "<prefix> <body>\n" with the prefix painted in prefixColor

View File

@@ -26,7 +26,7 @@ func TestMessageMethodsPlain(t *testing.T) {
{"Error", func(w *Writer) { w.Error("boom") }, "🛑 ERROR: boom\n"},
{"Progress", func(w *Writer) { w.Progress("p") }, " 》 p\n"},
{"Detail", func(w *Writer) { w.Detail("d") }, " 》 d\n"},
{"Banner", func(w *Writer) { w.Banner("hello") }, "hello\n"},
{"Banner", func(w *Writer) { w.Banner("hello") }, "hello\n"}, // plain mode, no bold
}
for _, tt := range tests {
@@ -69,6 +69,15 @@ func TestColorOutputContainsANSI(t *testing.T) {
}
}
func TestBannerBoldWhenColor(t *testing.T) {
w, buf := newTestWriter(true)
w.Banner("hello")
out := buf.String()
if !strings.Contains(out, "\033[1m") {
t.Errorf("expected bold ANSI escape in colored Banner output, got %q", out)
}
}
func TestValueFormattersPlain(t *testing.T) {
w, _ := newTestWriter(false)