Documentation ¶
Overview ¶
ColoredCobra allows you to colorize Cobra's text output, 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 cc "github.com/crinklywrappr/coloredcobra"
2. Put the following code to the beginning of the Execute() function:
cc.Init(&cc.Config{ RootCmd: rootCmd, Headings: cc.Bold + cc.Underline, Commands: cc.Yellow + cc.Bold, ExecName: cc.Bold, Flags: cc.Bold, })
3. Build & execute your code.
Copyright © 2022 Ivan Pirog <ivan.pirog@gmail.com>. Released under the MIT license. Project home: https://github.com/crinklywrappr/coloredcobra
Index ¶
Constants ¶
View Source
const ( None = 0 Black = 1 Red = 2 Green = 3 Yellow = 4 Blue = 5 Magenta = 6 Cyan = 7 White = 8 HiRed = 9 HiGreen = 10 HiYellow = 11 HiBlue = 12 HiMagenta = 13 HiCyan = 14 HiWhite = 15 Bold = 16 Italic = 32 Underline = 64 )
Constants for colors and B, I, U
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { RootCmd *cobra.Command Headings uint8 Commands uint8 CmdShortDescr uint8 ExecName uint8 Flags uint8 FlagsDataType uint8 FlagsDescr uint8 Aliases uint8 Example uint8 NoExtraNewlines bool NoBottomNewline bool }
Config is a settings structure which sets styles for individual parts of Cobra text output.
Note that RootCmd is required.
Example:
c := &cc.Config{ RootCmd: rootCmd, Headings: cc.HiWhite + cc.Bold + cc.Underline, Commands: cc.Yellow + cc.Bold, CmdShortDescr: cc.Cyan, ExecName: cc.Bold, Flags: cc.Bold, Aliases: cc.Bold, Example: cc.Italic, }
Click to show internal directories.
Click to hide internal directories.