Documentation
¶
Overview ¶
StyledCobra allows you to colorize Cobra's text output using lipgloss, making it look better using simple settings to customize individual parts of console output.
Usage example:
1. Insert in cmd/root.go file of your project :
import (
"github.com/auribuo/stylishcobra"
"github.com/charmbracelet/lipgloss"
)
2. Put the following code to the beginning of the Execute() function:
stylishcobra.Setup(rootCmd).
StyleHeadings(lipgloss.NewStyle().Underline(true).Bold(true).Foreground(lipgloss.ANSIColor(termenv.ANSICyan))).
StyleCommands(lipgloss.NewStyle().Foreground(lipgloss.ANSIColor(termenv.ANSIYellow)).Bold(true)).
StyleAliases(lipgloss.NewStyle().Bold(true).Italic(true)).
StyleCmdShortDescr(lipgloss.NewStyle().Foreground(lipgloss.ANSIColor(termenv.ANSIGreen))).
StyleExample(lipgloss.NewStyle().Italic(true)).
StyleExecName(lipgloss.NewStyle().Bold(true)).
StyleFlags(lipgloss.NewStyle().Bold(true)).
StyleFlagsDescr(lipgloss.NewStyle().Foreground(lipgloss.ANSIColor(termenv.ANSIRed))).
StyleFlagsDataType(lipgloss.NewStyle().Foreground(lipgloss.Color("#444444")).Italic(true)).
Init()
3. Build & execute your code.
Copyright © 2024 Aurelio Buonomo Released under the MIT license.
Index ¶
- func Init(cfg *Config)
- type Config
- func (cfg *Config) DisableBottomNewline() *Config
- func (cfg *Config) DisableExtraNewlines() *Config
- func (cfg *Config) EnableBottomNewline() *Config
- func (cfg *Config) EnableExtraNewlines() *Config
- func (cfg *Config) Init()
- func (cfg *Config) StyleAliases(style lipgloss.Style) *Config
- func (cfg *Config) StyleCmdShortDescr(style lipgloss.Style) *Config
- func (cfg *Config) StyleCommands(style lipgloss.Style) *Config
- func (cfg *Config) StyleExample(style lipgloss.Style) *Config
- func (cfg *Config) StyleExecName(style lipgloss.Style) *Config
- func (cfg *Config) StyleFlags(style lipgloss.Style) *Config
- func (cfg *Config) StyleFlagsDataType(style lipgloss.Style) *Config
- func (cfg *Config) StyleFlagsDescr(style lipgloss.Style) *Config
- func (cfg *Config) StyleHeadings(style lipgloss.Style) *Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
RootCmd *cobra.Command
Headings *lipgloss.Style
Commands *lipgloss.Style
CmdShortDescr *lipgloss.Style
ExecName *lipgloss.Style
Flags *lipgloss.Style
FlagsDataType *lipgloss.Style
FlagsDescr *lipgloss.Style
Aliases *lipgloss.Style
Example *lipgloss.Style
NoExtraNewlines bool
NoBottomNewline bool
}
Config contains all the styles that can be applied using stylishcobra. Use `Setup()` to start a builder to configure. Optionally you can also instanciate your own instance
func (*Config) DisableBottomNewline ¶
func (*Config) DisableExtraNewlines ¶
func (*Config) EnableBottomNewline ¶
func (*Config) EnableExtraNewlines ¶
func (*Config) Init ¶
func (cfg *Config) Init()
Init patches Cobra's usage template with configuration provided.
func (*Config) StyleCmdShortDescr ¶
func (*Config) StyleFlagsDataType ¶
Click to show internal directories.
Click to hide internal directories.

