Skip to content
Myr

options.go

This file

Path

style/options.go

70 lines · 4.7 KiB · Go

Last changed by

feat: --no-strip-ansi (#784)Carlos Alexandro Beckerbefore adoption4cedf9f

History of this file

Take it

1package style23// Options is the customization options for the style command.4type Options struct {5	Text      []string        `arg:"" optional:"" help:"Text to which to apply the style"`6	Trim      bool            `help:"Trim whitespaces on every input line" default:"false"`7	StripANSI bool            `help:"Strip ANSI sequences when reading from STDIN" default:"true" negatable:"" env:"GUM_STYLE_STRIP_ANSI"`8	Style     StylesNotHidden `embed:""`9}1011// Styles is a flag set of possible styles.12//13// It corresponds to the available options in the lipgloss.Style struct.14//15// This flag set is used in other parts of the application to embed styles for16// components, through embedding and prefixing.17type Styles struct {18	// Colors19	Foreground string `help:"Foreground Color" default:"${defaultForeground}" group:"Style Flags" env:"FOREGROUND"`20	Background string `help:"Background Color" default:"${defaultBackground}" group:"Style Flags" env:"BACKGROUND"`2122	// Border23	Border           string `help:"Border Style" enum:"none,hidden,normal,rounded,thick,double" default:"${defaultBorder}" group:"Style Flags" env:"BORDER" hidden:"true"`24	BorderBackground string `help:"Border Background Color" group:"Style Flags" default:"${defaultBorderBackground}" env:"BORDER_BACKGROUND" hidden:"true"`25	BorderForeground string `help:"Border Foreground Color" group:"Style Flags" default:"${defaultBorderForeground}" env:"BORDER_FOREGROUND" hidden:"true"`2627	// Layout28	Align   string `help:"Text Alignment" enum:"left,center,right,bottom,middle,top" default:"${defaultAlign}" group:"Style Flags" env:"ALIGN" hidden:"true"`29	Height  int    `help:"Text height" default:"${defaultHeight}" group:"Style Flags" env:"HEIGHT" hidden:"true"`30	Width   int    `help:"Text width" default:"${defaultWidth}" group:"Style Flags" env:"WIDTH" hidden:"true"`31	Margin  string `help:"Text margin" default:"${defaultMargin}" group:"Style Flags" env:"MARGIN" hidden:"true"`32	Padding string `help:"Text padding" default:"${defaultPadding}" group:"Style Flags" env:"PADDING" hidden:"true"`3334	// Format35	Bold          bool `help:"Bold text" default:"${defaultBold}" group:"Style Flags" env:"BOLD" hidden:"true"`36	Faint         bool `help:"Faint text" default:"${defaultFaint}" group:"Style Flags" env:"FAINT" hidden:"true"`37	Italic        bool `help:"Italicize text" default:"${defaultItalic}" group:"Style Flags" env:"ITALIC" hidden:"true"`38	Strikethrough bool `help:"Strikethrough text" default:"${defaultStrikethrough}" group:"Style Flags" env:"STRIKETHROUGH" hidden:"true"`39	Underline     bool `help:"Underline text" default:"${defaultUnderline}" group:"Style Flags" env:"UNDERLINE" hidden:"true"`40}4142// StylesNotHidden allows the style struct to display full help when not-embedded.43//44// NB: We must duplicate this struct to ensure that `gum style` does not hide45// flags when an error pops up. Ideally, we can dynamically hide or show flags46// based on the command run: https://github.com/alecthomas/kong/issues/31647type StylesNotHidden struct {48	// Colors49	Foreground string `help:"Foreground Color" default:"${defaultForeground}" group:"Style Flags" env:"FOREGROUND"`50	Background string `help:"Background Color" default:"${defaultBackground}" group:"Style Flags" env:"BACKGROUND"`5152	// Border53	Border           string `help:"Border Style" enum:"none,hidden,normal,rounded,thick,double" default:"${defaultBorder}" group:"Style Flags" env:"BORDER"`54	BorderBackground string `help:"Border Background Color" group:"Style Flags" default:"${defaultBorderBackground}" env:"BORDER_BACKGROUND"`55	BorderForeground string `help:"Border Foreground Color" group:"Style Flags" default:"${defaultBorderForeground}" env:"BORDER_FOREGROUND"`5657	// Layout58	Align   string `help:"Text Alignment" enum:"left,center,right,bottom,middle,top" default:"${defaultAlign}" group:"Style Flags" env:"ALIGN"`59	Height  int    `help:"Text height" default:"${defaultHeight}" group:"Style Flags" env:"HEIGHT"`60	Width   int    `help:"Text width" default:"${defaultWidth}" group:"Style Flags" env:"WIDTH"`61	Margin  string `help:"Text margin" default:"${defaultMargin}" group:"Style Flags" env:"MARGIN"`62	Padding string `help:"Text padding" default:"${defaultPadding}" group:"Style Flags" env:"PADDING"`6364	// Format65	Bold          bool `help:"Bold text" default:"${defaultBold}" group:"Style Flags" env:"BOLD"`66	Faint         bool `help:"Faint text" default:"${defaultFaint}" group:"Style Flags" env:"FAINT"`67	Italic        bool `help:"Italicize text" default:"${defaultItalic}" group:"Style Flags" env:"ITALIC"`68	Strikethrough bool `help:"Strikethrough text" default:"${defaultStrikethrough}" group:"Style Flags" env:"STRIKETHROUGH"`69	Underline     bool `help:"Underline text" default:"${defaultUnderline}" group:"Style Flags" env:"UNDERLINE"`70}