Merge feature/banner-bold-newline
All checks were successful
check / check (push) Successful in 1m55s
All checks were successful
check / check (push) Successful in 1m55s
This commit is contained in:
@@ -51,6 +51,7 @@ func setupGlobals(lc fx.Lifecycle, g *globals.Globals, v *vaultik.Vaultik, opts
|
|||||||
g.ShortCommit(), g.CommitDate,
|
g.ShortCommit(), g.CommitDate,
|
||||||
g.StartTime.Format(time.RFC3339))
|
g.StartTime.Format(time.RFC3339))
|
||||||
v.UI.Banner("%s", globals.Homepage)
|
v.UI.Banner("%s", globals.Homepage)
|
||||||
|
v.UI.Banner("")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -153,10 +153,14 @@ func (w *Writer) Progress(format string, args ...any) {
|
|||||||
w.emit(ansiWhite, " "+Marker, "", format, args)
|
w.emit(ansiWhite, " "+Marker, "", format, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Banner prints a line with no marker, left-aligned. Used for the
|
// Banner prints a line with no marker, left-aligned. Bold when color
|
||||||
// application startup banner only.
|
// is enabled. Used for the application startup banner only.
|
||||||
func (w *Writer) Banner(format string, args ...any) {
|
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
|
// emit writes "<prefix> <body>\n" with the prefix painted in prefixColor
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func TestMessageMethodsPlain(t *testing.T) {
|
|||||||
{"Error", func(w *Writer) { w.Error("boom") }, "🛑 ERROR: boom\n"},
|
{"Error", func(w *Writer) { w.Error("boom") }, "🛑 ERROR: boom\n"},
|
||||||
{"Progress", func(w *Writer) { w.Progress("p") }, " 》 p\n"},
|
{"Progress", func(w *Writer) { w.Progress("p") }, " 》 p\n"},
|
||||||
{"Detail", func(w *Writer) { w.Detail("d") }, " 》 d\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 {
|
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) {
|
func TestValueFormattersPlain(t *testing.T) {
|
||||||
w, _ := newTestWriter(false)
|
w, _ := newTestWriter(false)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user