2026-01-31 10:27:04 +00:00
|
|
|
package cli
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
import "fmt"
|
2026-01-31 10:27:04 +00:00
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// Sprintf formats a string (fmt.Sprintf wrapper).
|
2026-01-31 10:27:04 +00:00
|
|
|
func Sprintf(format string, args ...any) string {
|
|
|
|
|
return fmt.Sprintf(format, args...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// Sprint formats using default formats (fmt.Sprint wrapper).
|
2026-01-31 10:27:04 +00:00
|
|
|
func Sprint(args ...any) string {
|
|
|
|
|
return fmt.Sprint(args...)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// Styled returns text with a style applied.
|
|
|
|
|
func Styled(style *AnsiStyle, text string) string {
|
2026-01-31 10:27:04 +00:00
|
|
|
return style.Render(text)
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// Styledf returns formatted text with a style applied.
|
|
|
|
|
func Styledf(style *AnsiStyle, format string, args ...any) string {
|
2026-01-31 10:27:04 +00:00
|
|
|
return style.Render(fmt.Sprintf(format, args...))
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// SuccessStr returns success-styled string.
|
2026-01-31 10:27:04 +00:00
|
|
|
func SuccessStr(msg string) string {
|
2026-01-31 22:56:52 +00:00
|
|
|
return SuccessStyle.Render(Glyph(":check:") + " " + msg)
|
2026-01-31 10:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// ErrorStr returns error-styled string.
|
2026-01-31 10:27:04 +00:00
|
|
|
func ErrorStr(msg string) string {
|
2026-01-31 22:56:52 +00:00
|
|
|
return ErrorStyle.Render(Glyph(":cross:") + " " + msg)
|
2026-01-31 10:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// WarnStr returns warning-styled string.
|
|
|
|
|
func WarnStr(msg string) string {
|
|
|
|
|
return WarningStyle.Render(Glyph(":warn:") + " " + msg)
|
2026-01-31 10:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// InfoStr returns info-styled string.
|
2026-01-31 10:27:04 +00:00
|
|
|
func InfoStr(msg string) string {
|
2026-01-31 22:56:52 +00:00
|
|
|
return InfoStyle.Render(Glyph(":info:") + " " + msg)
|
2026-01-31 10:27:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-31 22:56:52 +00:00
|
|
|
// DimStr returns dim-styled string.
|
2026-01-31 10:27:04 +00:00
|
|
|
func DimStr(msg string) string {
|
|
|
|
|
return DimStyle.Render(msg)
|
2026-01-31 22:56:52 +00:00
|
|
|
}
|