From 75564a504eb5427fd8048f7ea53ad218daa6f8fc Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 17 Jun 2026 05:52:03 +0200 Subject: [PATCH] Bold the startup banner on TTY; blank line after banner --- internal/cli/app.go | 1 + internal/ui/ui.go | 10 +++++++--- internal/ui/ui_test.go | 11 ++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/cli/app.go b/internal/cli/app.go index 4217d54..0dfa599 100644 --- a/internal/cli/app.go +++ b/internal/cli/app.go @@ -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 }, diff --git a/internal/ui/ui.go b/internal/ui/ui.go index 8b93881..f0f55c8 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -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 " \n" with the prefix painted in prefixColor diff --git a/internal/ui/ui_test.go b/internal/ui/ui_test.go index cb18331..4eef683 100644 --- a/internal/ui/ui_test.go +++ b/internal/ui/ui_test.go @@ -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)