Documentation ¶
Overview ¶
Package console implements console printing helpers
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Print prints a message. Print = func(data ...interface{}) { consolePrint("Print", getThemeColor("Print"), data...) } // PrintC prints a message with color. PrintC = func(data ...interface{}) { consolePrint("PrintC", getThemeColor("PrintC"), data...) } // Printf prints a formatted message. Printf = func(format string, data ...interface{}) { consolePrintf("Print", getThemeColor("Print"), format, data...) } // Println prints a message with a newline. Println = func(data ...interface{}) { consolePrintln("Print", getThemeColor("Print"), data...) } // Fatal print a error message and exit. Fatal = func(data ...interface{}) { consolePrint("Fatal", getThemeColor("Fatal"), data...) os.Exit(1) } // Fatalf print a error message with a format specified and exit. Fatalf = func(format string, data ...interface{}) { consolePrintf("Fatal", getThemeColor("Fatal"), format, data...) os.Exit(1) } // Fatalln print a error message with a new line and exit. Fatalln = func(data ...interface{}) { consolePrintln("Fatal", getThemeColor("Fatal"), data...) os.Exit(1) } // Error prints a error message. Error = func(data ...interface{}) { consolePrint("Error", getThemeColor("Error"), data...) } // Errorf print a error message with a format specified. Errorf = func(format string, data ...interface{}) { consolePrintf("Error", getThemeColor("Error"), format, data...) } // Errorln prints a error message with a new line. Errorln = func(data ...interface{}) { consolePrintln("Error", getThemeColor("Error"), data...) } // Info prints a informational message. Info = func(data ...interface{}) { consolePrint("Info", getThemeColor("Info"), data...) } // Infof prints a informational message in custom format. Infof = func(format string, data ...interface{}) { consolePrintf("Info", getThemeColor("Info"), format, data...) } // Infoln prints a informational message with a new line. Infoln = func(data ...interface{}) { consolePrintln("Info", getThemeColor("Info"), data...) } // Debug prints a debug message without a new line // Debug prints a debug message. Debug = func(data ...interface{}) { consolePrint("Debug", getThemeColor("Debug"), data...) } // Debugf prints a debug message with a new line. Debugf = func(format string, data ...interface{}) { consolePrintf("Debug", getThemeColor("Debug"), format, data...) } // Debugln prints a debug message with a new line. Debugln = func(data ...interface{}) { consolePrintln("Debug", getThemeColor("Debug"), data...) } // Colorize prints message in a colorized form, dictated by the corresponding tag argument. Colorize = func(tag string, data interface{}) string { if isatty.IsTerminal(os.Stdout.Fd()) { colorized := getThemeColor(tag) if colorized != nil { return colorized.SprintFunc()(data) } } return fmt.Sprint(data) } // Eraseline Print in new line and adjust to top so that we don't print over the ongoing progress bar. Eraseline = func() { consolePrintf("Print", getThemeColor("Print"), "%c[2K\n", 27) consolePrintf("Print", getThemeColor("Print"), "%c[A", 27) } )
Functions ¶
func ProgramName ¶
func ProgramName() string
ProgramName - return the name of the executable program.
func RewindLines ¶
func RewindLines(n int)
RewindLines - uses terminal escape symbols to clear and rewind upwards on the console for `n` lines.
Types ¶
type Table ¶
type Table struct { // per-row colors RowColors []*color.Color // per-column align-right flag (aligns left by default) AlignRight []bool // Left margin width for table TableIndentWidth int // Flag to print separator under heading. Row 0 is considered heading HeaderRowSeparator bool }
Table - data to print in table format with fixed row widths.
func NewTable ¶
NewTable - create a new Table instance. Takes per-row colors and per-column right-align flags and table indentation width (i.e. left margin width)
func (*Table) DisplayTable ¶
DisplayTable - prints the table
Click to show internal directories.
Click to hide internal directories.