style

package
v0.0.0-...-0499334 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const LocalRunNameTag = "(local)"

Variables

This section is empty.

Functions

func Bold

func Bold(text string) string

Bold brightly emboldens the provided text

func Bright

func Bright(text string) string

Bright is a strong bold version of the text

func Chevron

func Chevron() string

Chevron returns the select chevron character for the current platform. Unfortunately "❱" does not display on Windows Powershell. Limit "❱" to non-Windows until support is known for other operating systems.

func CommandText

func CommandText(text string) string

CommandText emphasizes command text

func Commandf

func Commandf(command string, isPrimary bool) string

TODO: this is reusing logic from process.go, but can't import because of circular dependencies

func Darken

func Darken(text string) string

Darken adds a bold gray shade to text

func Emoji

func Emoji(alias string) string

func Error

func Error(text string) string

func ExampleCommandsf

func ExampleCommandsf(commands []ExampleCommand) string

ExampleCommandsf returns a multiline string of commands and comments

func ExampleTemplatef

func ExampleTemplatef(template string) string

ExampleTemplatef indents and styles command examples for the help messages

func Faint

func Faint(text string) string

Faint resets all effects then decreases text intensity

func Gray

func Gray(text string) string

Gray applies a subdued gray color to text

func Green

func Green(text string) string

Green applies green color to text without bold

func Header(text string) string

func Highlight

func Highlight(text string) string

Highlight adds emphasis to text

func HomePath

func HomePath(filepath string) string

HomePath replaces the home directory with the shorthand "~" in a filepath

func Indent

func Indent(text string) string

func Input

func Input(text string) string

func IsLipglossEnabled

func IsLipglossEnabled() bool

IsLipglossEnabled reports whether lipgloss styling is active

func LinkText

func LinkText(path string) string

LinkText underlines and formats the provided path

func LocalRunDisplayName

func LocalRunDisplayName(name string) string

LocalRunDisplayName appends the (local) tag to apps created by the run command

func Mapf

func Mapf(m map[string]string) string

Create inline padding to display map rows in clean way

func Pluralize

func Pluralize(singular string, plural string, count int) string

Lexical

func PrintTemplate

func PrintTemplate(w io.Writer, tmpl string, data any) (err error)

PrintTemplate outputs the template with data to the writer or errors

Note: Templates use the Go standard library template package https://pkg.go.dev/text/template

func Red

func Red(text string) string

Red applies red color to text without bold

func RemoveANSI

func RemoveANSI(str string) string

RemoveANSI uses regex to strip ANSI colour codes

Shamelessly stolen from https://github.com/acarl005/stripansi/blob/master/stripansi.go

func RemoveEmoji

func RemoveEmoji(str string) string

RemoveEmoji strips non-ASCII characters (such as emoji) from a string and collapses any resulting extra whitespace.

https://en.wikipedia.org/wiki/ASCII#Printable_character_table

func Secondary

func Secondary(text string) string

Secondary dims the displayed text

func SectionHeaderf

func SectionHeaderf(emoji, text string) string

SectionHeaderf returns a standard formatted section header TODO - support the the arg text ...string to do formatting

func SectionSecondaryf

func SectionSecondaryf(format string, a ...interface{}) string

SectionSecondaryf returns a standard formatted section secondary text

func Sectionf

func Sectionf(section TextSection) string

Standardize text section formatting

func Selector

func Selector(text string) string

func Separator

func Separator() string

func StyleFlags

func StyleFlags(text string) string

StyleFlags post-processes Cobra's FlagUsages() output to colorize flag names and descriptions.

func Styler

func Styler() *aurora.Aurora

DEPRECATED: Styler returns an aurora instance for legacy styling. Use the style functions (Secondary, CommandText, Error, etc.) instead.

func TeamSelectLabel

func TeamSelectLabel(teamDomain string, teamID string) string

TeamSelectLabel formats a team label with the teamID

func ThemeSlack

func ThemeSlack() huh.Theme

ThemeSlack returns a huh Theme styled with Slack brand colors.

func ThemeSurvey

func ThemeSurvey() huh.Theme

ThemeSurvey returns a huh Theme that matches the legacy survey prompt styling. Applied when experiment.Lipgloss is off.

func TimeAgo

func TimeAgo(datetime int) string

TimeAgo formats the time since the provided datetime into a friendly format

func ToggleLipgloss

func ToggleLipgloss(active bool)

ToggleLipgloss enables lipgloss-based styling when set to true

func ToggleSpinner

func ToggleSpinner(spins bool)

ToggleSpinner enables the animation when spins is true, otherwise disables it

func ToggleStyles

func ToggleStyles(active bool)

ToggleStyles sets styles and formatting values to the active state

func Tracef

func Tracef(traceID string, traceValues ...string) string

Tracef prepares the output string for a test trace ID with optional values

Formatted as TRACE_ID or TRACE_ID=VALUE or TRACE_ID=VALUE,VALUE,VALUE

func Underline

func Underline(text string) string

Underline underscores the given text

func Warning

func Warning(text string) string

func Yellow

func Yellow(text string) string

Yellow applies yellow color to text without bold

Types

type ExampleCommand

type ExampleCommand struct {
	// Command is the command to be run, not including the process name
	Command string
	// Meaning plainly describes the result of running the command
	Meaning string
}

ExampleCommand contains a command with a descriptive meaning

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner is a stylized object to indicate loading text

func NewSpinner

func NewSpinner(writer io.Writer) *Spinner

NewSpinner creates a spinner that will write to writer

func (*Spinner) Active

func (s *Spinner) Active() bool

Active is true if the spinner is started

func (*Spinner) Start

func (s *Spinner) Start()

Start makes the spinner active with prepared text

func (*Spinner) Status

func (s *Spinner) Status() (string, bool)

Status returns the current spinner text and spin status

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop halts the spinning and displays completion text

func (*Spinner) Update

func (s *Spinner) Update(text string, icon string) *Spinner

Update replaces the spinner text and icon

type TemplateData

type TemplateData map[string]interface{}

TemplateData contains any optional values to include in the formatted message

Note: A custom template function should also be added for custom values

type TextSection

type TextSection struct {
	Emoji     string
	Text      string
	Secondary []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL