Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find features des...' (#60) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Some checks are pending
Security Scan / security (push) Waiting to run

This commit is contained in:
Virgil 2026-04-02 06:31:27 +00:00
commit a0427d4b7e
2 changed files with 20 additions and 0 deletions

View file

@ -14,11 +14,17 @@ func Sprint(args ...any) string {
// Styled returns text with a style applied. // Styled returns text with a style applied.
func Styled(style *AnsiStyle, text string) string { func Styled(style *AnsiStyle, text string) string {
if style == nil {
return compileGlyphs(text)
}
return style.Render(compileGlyphs(text)) return style.Render(compileGlyphs(text))
} }
// Styledf returns formatted text with a style applied. // Styledf returns formatted text with a style applied.
func Styledf(style *AnsiStyle, format string, args ...any) string { func Styledf(style *AnsiStyle, format string, args ...any) string {
if style == nil {
return compileGlyphs(fmt.Sprintf(format, args...))
}
return style.Render(compileGlyphs(fmt.Sprintf(format, args...))) return style.Render(compileGlyphs(fmt.Sprintf(format, args...)))
} }

View file

@ -222,3 +222,17 @@ func TestPad_Good(t *testing.T) {
assert.Equal(t, "hello", Pad("hello", 3)) assert.Equal(t, "hello", Pad("hello", 3))
assert.Equal(t, "東京 ", Pad("東京", 6)) assert.Equal(t, "東京 ", Pad("東京", 6))
} }
func TestStyled_Good_NilStyle(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
assert.Equal(t, "hello [OK]", Styled(nil, "hello :check:"))
}
func TestStyledf_Good_NilStyle(t *testing.T) {
restoreThemeAndColors(t)
UseASCII()
assert.Equal(t, "value: [WARN]", Styledf(nil, "value: %s", ":warn:"))
}