Documentation ¶
Index ¶
- Constants
- Variables
- func ColorBlue(s string) string
- func ColorCyan(s string) string
- func ColorGray(s string) string
- func ColorGreen(s string) string
- func ColorMagenta(s string) string
- func ColorRed(s string) string
- func ColorYellow(s string) string
- func Eprint(args ...any) (int, error)
- func Eprintf(format string, args ...any) (int, error)
- func Eprintln(args ...any) (int, error)
- func GetSize() (int, int, error)
- func IndentString(indent int) string
- func InitializeColorization(colorize string) (CleanupFunc, CleanupFunc, error)
- func Options(options []string) string
- func Print(args ...any) (int, error)
- func PrintIndent(indent int)
- func Printf(format string, args ...any) (int, error)
- func Println(args ...any) (int, error)
- func StylizedOptions(options []string, colorizer Colorizer) string
- type CleanupFunc
- type Colorizer
- type Stylist
- type Table
- type TableStyle
- type TreePrefix
Constants ¶
View Source
const ( ResetCode = escapePrefix + "0" + escapeSuffix RedCode = escapePrefix + "31" + escapeSuffix GreenCode = escapePrefix + "32" + escapeSuffix YellowCode = escapePrefix + "33" + escapeSuffix BlueCode = escapePrefix + "34" + escapeSuffix MagentaCode = escapePrefix + "35" + escapeSuffix CyanCode = escapePrefix + "36" + escapeSuffix GrayCode = escapePrefix + "90" + escapeSuffix )
View Source
const IndentSpaces = 2
Variables ¶
View Source
var ColorizeStderr bool
View Source
var ColorizeStdout bool
View Source
var Indent = strings.Repeat(" ", IndentSpaces)
View Source
var Quiet bool = false
View Source
var StderrStylist = NewStylist(false)
View Source
var StdoutStylist = NewStylist(false)
Functions ¶
func IndentString ¶
func InitializeColorization ¶ added in v0.3.9
func InitializeColorization(colorize string) (CleanupFunc, CleanupFunc, error)
Attempts to enable colorization for os.Stdout and os.Stderr according to the colorize argument. If it succeeds it may return two [CleanupFunc]s that should be called to restore os.Stdout and os.Stderr to their original mode. The [CleanupFunc]s may also be nil.
The colorize argument can be:
- "true", "TRUE", "True", "t", "T", "1": Attempts to enable colorization if os.Stdout and os.Stdout support it. If it succeeds will set ColorizeStdout, StdoutStylist, ColorizeStderr, and StderrStylist accordingly.
- "false", "FALSE", "False", "f", "F", "0": Does nothing.
- "force": Sets ColorizeStdout, StdoutStylist, ColorizeStderr, and StderrStylist as if coloriziation were enabled.
Other colorize values will return an error.
func PrintIndent ¶
func PrintIndent(indent int)
func StylizedOptions ¶ added in v0.1.24
Types ¶
type CleanupFunc ¶ added in v0.3.9
type CleanupFunc func() error
func EnableColor ¶
func EnableColor(file *os.File) (bool, CleanupFunc, error)
Returns true if the file supports colorization.
type Stylist ¶ added in v0.1.24
type Stylist struct {
Colorize bool
}
func NewStylist ¶ added in v0.1.24
type Table ¶
type Table struct { Rows [][][]string Style TableStyle MaxWidth int HeadingSeparator string RowSeparator string TopDividerSeparator string TopDivider string MiddleDividerSeparator string MiddleDivider string BottomDividerSeparator string BottomDivider string }
func (*Table) ColumnWidths ¶
type TableStyle ¶
type TableStyle int
const ( TopSeparatorTableStyle TableStyle = 1 << iota ColumnSeparatorTableStyle RowSeparatorTableStyle BottomSeparatorTableStyle )
type TreePrefix ¶
type TreePrefix []bool
func (TreePrefix) Print ¶
func (self TreePrefix) Print(indent int, last bool)
Click to show internal directories.
Click to hide internal directories.