Documentation
¶
Overview ¶
Package fang provides styling for cobra commands.
Index ¶
- func DefaultErrorHandler(w io.Writer, styles Styles, err error)
- func Execute(ctx context.Context, root *cobra.Command, options ...Option) error
- func StyleExamples(c *cobra.Command, styles Styles) []string
- func StyleUsage(c *cobra.Command, styles Program, complete bool) string
- type Codeblock
- type ColorScheme
- type ColorSchemeFunc
- type ErrorHandler
- type HelpContext
- type HelpRenderer
- type Option
- func WithColorSchemeFunc(cs ColorSchemeFunc) Option
- func WithCommit(commit string) Option
- func WithErrorHandler(handler ErrorHandler) Option
- func WithHelpRenderer(renderer HelpRenderer) Option
- func WithNotifySignal(signals ...os.Signal) Option
- func WithTheme(theme ColorScheme) Optiondeprecated
- func WithVersion(version string) Option
- func WithoutCompletions() Option
- func WithoutManpage() Option
- func WithoutVersion() Option
- type Program
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultErrorHandler ¶
DefaultErrorHandler is the default ErrorHandler implementation.
func StyleExamples ¶
StyleExamples stylizes example lines for a given command.
Types ¶
type Codeblock ¶
type Codeblock struct {
Base lipgloss.Style
Program Program
Text lipgloss.Style
Comment lipgloss.Style
}
Codeblock styles.
type ColorScheme ¶
type ColorScheme struct {
Base color.Color
Title color.Color
Description color.Color
Codeblock color.Color
Program color.Color
DimmedArgument color.Color
Comment color.Color
Flag color.Color
FlagDefault color.Color
Command color.Color
QuotedString color.Color
Argument color.Color
Help color.Color
Dash color.Color
ErrorHeader [2]color.Color // 0=fg 1=bg
ErrorDetails color.Color
}
ColorScheme describes a colorscheme.
func AnsiColorScheme ¶
func AnsiColorScheme(c lipgloss.LightDarkFunc) ColorScheme
AnsiColorScheme is a ANSI colorscheme.
func DefaultColorScheme ¶
func DefaultColorScheme(c lipgloss.LightDarkFunc) ColorScheme
DefaultColorScheme is the default colorscheme.
func DefaultTheme
deprecated
func DefaultTheme(isDark bool) ColorScheme
DefaultTheme is the default colorscheme.
Deprecated: use DefaultColorScheme instead.
type ColorSchemeFunc ¶
type ColorSchemeFunc = func(lipgloss.LightDarkFunc) ColorScheme
ColorSchemeFunc gets a lipgloss.LightDarkFunc and returns a ColorScheme.
type ErrorHandler ¶
ErrorHandler handles an error, printing them to the given io.Writer.
type HelpContext ¶
type HelpContext struct {
Writer *colorprofile.Writer
Styles Styles
Width int
}
HelpContext contains styling and writer helpers for custom help rendering.
type HelpRenderer ¶
type HelpRenderer func(cmd *cobra.Command, ctx HelpContext)
HelpRenderer renders command help using Fang styling primitives.
type Option ¶
type Option func(*settings)
Option changes fang settings.
func WithColorSchemeFunc ¶
func WithColorSchemeFunc(cs ColorSchemeFunc) Option
WithColorSchemeFunc sets a function that return colorscheme.
func WithErrorHandler ¶
func WithErrorHandler(handler ErrorHandler) Option
WithErrorHandler sets the error handler.
func WithHelpRenderer ¶
func WithHelpRenderer(renderer HelpRenderer) Option
WithHelpRenderer sets a custom help renderer.
func WithNotifySignal ¶
WithNotifySignal sets the signals that should interrupt the execution of the program.
func WithTheme
deprecated
func WithTheme(theme ColorScheme) Option
WithTheme sets the colorscheme.
Deprecated: use WithColorSchemeFunc instead.
func WithoutVersion ¶
func WithoutVersion() Option
WithoutVersion skips the `-v`/`--version` functionality.
