Merge pull request '[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ...' (#46) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
All checks were successful
Security Scan / security (push) Successful in 19s

This commit is contained in:
Virgil 2026-04-02 05:03:43 +00:00
commit ee2c0691a4
3 changed files with 36 additions and 17 deletions

View file

@ -38,7 +38,7 @@ func Text(args ...any) {
// Success prints a success message with checkmark (green). // Success prints a success message with checkmark (green).
func Success(msg string) { func Success(msg string) {
fmt.Println(SuccessStyle.Render(Glyph(":check:") + " " + msg)) fmt.Println(SuccessStyle.Render(Glyph(":check:") + " " + compileGlyphs(msg)))
} }
// Successf prints a formatted success message. // Successf prints a formatted success message.
@ -49,7 +49,7 @@ func Successf(format string, args ...any) {
// Error prints an error message with cross (red) to stderr and logs it. // Error prints an error message with cross (red) to stderr and logs it.
func Error(msg string) { func Error(msg string) {
LogError(msg) LogError(msg)
fmt.Fprintln(os.Stderr, ErrorStyle.Render(Glyph(":cross:")+" "+msg)) fmt.Fprintln(os.Stderr, ErrorStyle.Render(Glyph(":cross:")+" "+compileGlyphs(msg)))
} }
// Errorf prints a formatted error message to stderr and logs it. // Errorf prints a formatted error message to stderr and logs it.
@ -86,7 +86,7 @@ func ErrorWrapAction(err error, verb string) {
// Warn prints a warning message with warning symbol (amber) to stderr and logs it. // Warn prints a warning message with warning symbol (amber) to stderr and logs it.
func Warn(msg string) { func Warn(msg string) {
LogWarn(msg) LogWarn(msg)
fmt.Fprintln(os.Stderr, WarningStyle.Render(Glyph(":warn:")+" "+msg)) fmt.Fprintln(os.Stderr, WarningStyle.Render(Glyph(":warn:")+" "+compileGlyphs(msg)))
} }
// Warnf prints a formatted warning message to stderr and logs it. // Warnf prints a formatted warning message to stderr and logs it.
@ -96,7 +96,7 @@ func Warnf(format string, args ...any) {
// Info prints an info message with info symbol (blue). // Info prints an info message with info symbol (blue).
func Info(msg string) { func Info(msg string) {
fmt.Println(InfoStyle.Render(Glyph(":info:") + " " + msg)) fmt.Println(InfoStyle.Render(Glyph(":info:") + " " + compileGlyphs(msg)))
} }
// Infof prints a formatted info message. // Infof prints a formatted info message.
@ -106,7 +106,7 @@ func Infof(format string, args ...any) {
// Dim prints dimmed text. // Dim prints dimmed text.
func Dim(msg string) { func Dim(msg string) {
fmt.Println(DimStyle.Render(msg)) fmt.Println(DimStyle.Render(compileGlyphs(msg)))
} }
// Progress prints a progress indicator that overwrites the current line. // Progress prints a progress indicator that overwrites the current line.
@ -127,7 +127,7 @@ func ProgressDone() {
// Label prints a "Label: value" line. // Label prints a "Label: value" line.
func Label(word, value string) { func Label(word, value string) {
fmt.Printf("%s %s\n", KeyStyle.Render(i18n.Label(word)), value) fmt.Printf("%s %s\n", KeyStyle.Render(i18n.Label(word)), compileGlyphs(value))
} }
// Scanln reads from stdin. // Scanln reads from stdin.
@ -140,14 +140,14 @@ func Scanln(a ...any) (int, error) {
// cli.Task("php", "Running tests...") // [php] Running tests... // cli.Task("php", "Running tests...") // [php] Running tests...
// cli.Task("go", i18n.Progress("build")) // [go] Building... // cli.Task("go", i18n.Progress("build")) // [go] Building...
func Task(label, message string) { func Task(label, message string) {
fmt.Printf("%s %s\n\n", DimStyle.Render("["+label+"]"), message) fmt.Printf("%s %s\n\n", DimStyle.Render("["+compileGlyphs(label)+"]"), compileGlyphs(message))
} }
// Section prints a section header: "── SECTION ──" // Section prints a section header: "── SECTION ──"
// //
// cli.Section("audit") // ── AUDIT ── // cli.Section("audit") // ── AUDIT ──
func Section(name string) { func Section(name string) {
header := "── " + strings.ToUpper(name) + " ──" header := "── " + strings.ToUpper(compileGlyphs(name)) + " ──"
fmt.Println(AccentStyle.Render(header)) fmt.Println(AccentStyle.Render(header))
} }
@ -156,7 +156,7 @@ func Section(name string) {
// cli.Hint("install", "composer require vimeo/psalm") // cli.Hint("install", "composer require vimeo/psalm")
// cli.Hint("fix", "core php fmt --fix") // cli.Hint("fix", "core php fmt --fix")
func Hint(label, message string) { func Hint(label, message string) {
fmt.Printf(" %s %s\n", DimStyle.Render(label+":"), message) fmt.Printf(" %s %s\n", DimStyle.Render(compileGlyphs(label)+":"), compileGlyphs(message))
} }
// Severity prints a severity-styled message. // Severity prints a severity-styled message.
@ -179,7 +179,7 @@ func Severity(level, message string) {
default: default:
style = DimStyle style = DimStyle
} }
fmt.Printf(" %s %s\n", style.Render("["+level+"]"), message) fmt.Printf(" %s %s\n", style.Render("["+compileGlyphs(level)+"]"), compileGlyphs(message))
} }
// Result prints a result line: "✓ message" or "✗ message" // Result prints a result line: "✓ message" or "✗ message"

View file

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"io" "io"
"os" "os"
"strings"
"testing" "testing"
) )
@ -99,3 +100,21 @@ func TestSemanticOutput(t *testing.T) {
t.Error("Result(false) output empty") t.Error("Result(false) output empty")
} }
} }
func TestSemanticOutput_GlyphShortcodes(t *testing.T) {
UseASCII()
out := captureOutput(func() {
Success("done :check:")
Task(":cross:", "running :warn:")
Section(":check: audit")
Hint(":info:", "apply :check:")
Label("status", "ready :warn:")
})
for _, want := range []string{"[OK]", "[FAIL]", "[WARN]"} {
if !strings.Contains(out, want) {
t.Fatalf("expected output to contain %q, got %q", want, out)
}
}
}

View file

@ -14,35 +14,35 @@ 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 {
return style.Render(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 {
return style.Render(fmt.Sprintf(format, args...)) return style.Render(compileGlyphs(fmt.Sprintf(format, args...)))
} }
// SuccessStr returns success-styled string. // SuccessStr returns success-styled string.
func SuccessStr(msg string) string { func SuccessStr(msg string) string {
return SuccessStyle.Render(Glyph(":check:") + " " + msg) return SuccessStyle.Render(Glyph(":check:") + " " + compileGlyphs(msg))
} }
// ErrorStr returns error-styled string. // ErrorStr returns error-styled string.
func ErrorStr(msg string) string { func ErrorStr(msg string) string {
return ErrorStyle.Render(Glyph(":cross:") + " " + msg) return ErrorStyle.Render(Glyph(":cross:") + " " + compileGlyphs(msg))
} }
// WarnStr returns warning-styled string. // WarnStr returns warning-styled string.
func WarnStr(msg string) string { func WarnStr(msg string) string {
return WarningStyle.Render(Glyph(":warn:") + " " + msg) return WarningStyle.Render(Glyph(":warn:") + " " + compileGlyphs(msg))
} }
// InfoStr returns info-styled string. // InfoStr returns info-styled string.
func InfoStr(msg string) string { func InfoStr(msg string) string {
return InfoStyle.Render(Glyph(":info:") + " " + msg) return InfoStyle.Render(Glyph(":info:") + " " + compileGlyphs(msg))
} }
// DimStr returns dim-styled string. // DimStr returns dim-styled string.
func DimStr(msg string) string { func DimStr(msg string) string {
return DimStyle.Render(msg) return DimStyle.Render(compileGlyphs(msg))
} }