Documentation
¶
Index ¶
- Constants
- Variables
- func AskConfirmation(message string, def bool) bool
- func AskString(message string, validator func(string) (string, bool)) string
- func AskStringDefault(message, def string, validator func(string) (string, bool)) string
- func Eprint(a ...interface{}) (n int, err error)
- func Eprintf(format string, a ...interface{}) (n int, err error)
- func Eprintfln(format string, a ...interface{}) (n int, err error)
- func Eprintln(a ...interface{}) (n int, err error)
- func Escape(msg []byte) []byte
- func EscapeTrailingBackslash(msg []byte) []byte
- func Format(msg string) string
- func FormatBlockMessage(format string, msg string) string
- func Formatf(msg string, a ...interface{}) string
- func GetLogLevel() int
- func GetSize() (width, height int)
- func HasNativeColorSupport(stream interface{}) bool
- func HasPosixColorSupport() bool
- func IsCI() bool
- func IsCygwinTTY(fd uintptr) bool
- func IsDebug() bool
- func IsInteractive(stream interface{}) bool
- func IsTerminal(stream interface{}) bool
- func IsVerbose() bool
- func Print(a ...interface{}) (n int, err error)
- func Printf(format string, a ...interface{}) (n int, err error)
- func Printfln(format string, a ...interface{}) (n int, err error)
- func Println(a ...interface{}) (n int, err error)
- func Scan(a ...interface{}) (n int, err error)
- func Scanf(format string, a ...interface{}) (n int, err error)
- func Scanln(a ...interface{}) (n int, err error)
- func SetLogLevel(level int) error
- func SymfonyStyle(stdout *ConsoleOutput, stdin *Input) style
- type Color
- type ConsoleOutput
- type Cursor
- func (c Cursor) ClearLine() Cursor
- func (c Cursor) ClearLineAfter() Cursor
- func (c Cursor) ClearOutput() Cursor
- func (c Cursor) ClearScreen() Cursor
- func (c Cursor) Hide() Cursor
- func (c Cursor) MoveDown(lines int) Cursor
- func (c Cursor) MoveLeft(columns int) Cursor
- func (c Cursor) MoveRight(columns int) Cursor
- func (c Cursor) MoveToColumn(column int) Cursor
- func (c Cursor) MoveToPosition(column, row int) Cursor
- func (c Cursor) MoveUp(lines int) Cursor
- func (c Cursor) RestorePosition() Cursor
- func (c Cursor) SavePosition() Cursor
- func (c Cursor) Show() Cursor
- type FdHolder
- type FdReader
- type Formatter
- func (formatter *Formatter) AddAlias(from, to string)
- func (formatter *Formatter) Format(msg []byte, w io.Writer) (written int, err error)
- func (formatter *Formatter) FormatBytes(msg []byte) ([]byte, error)
- func (formatter *Formatter) HasStyle(name string) bool
- func (formatter *Formatter) SetStyle(name string, style *FormatterStyle)
- type FormatterStyle
- type Input
- type Output
- type Spinner
Constants ¶
const (
ErrNotATTY = termErr(0)
)
Variables ¶
var ( FormattingRegexp = regexp.MustCompile("(?i)<((" + tagRegex + ")?|/(" + tagRegex + ")?)>") StyleRegexp = regexp.MustCompile("(?i)([^=]+)=([^;]+)(;|$)") EscapingRegexp = regexp.MustCompile("([^\\\\]?)<") )
var ( Logger zerolog.Logger LogLevels = map[int]zerolog.Level{ 1: zerolog.ErrorLevel, 2: zerolog.WarnLevel, 3: zerolog.InfoLevel, 4: zerolog.DebugLevel, 5: zerolog.TraceLevel, } )
var ( DefaultStdout *ConsoleOutput Stdout *ConsoleOutput Stderr *Output DiscardedOutput *Output )
var ( IsTTY = isattypkg.IsTerminal MakeRaw = term.MakeRaw Restore = term.Restore )
var ( Stdin = &Input{ reader: os.Stdin, interactive: IsTerminal(os.Stdin) && IsTerminal(os.Stdout), } )
Functions ¶
func AskConfirmation ¶
func AskStringDefault ¶
func Eprint ¶
Eprint formats using the default formats for its operands and writes to standard error output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Eprintf ¶
Eprintf formats according to a format specifier and writes to standard error output. It returns the number of bytes written and any write error encountered.
func Eprintfln ¶
Eprintfln formats according to a format specifier and writes to standard error output. A newline is appended. It returns the number of bytes written and any write error encountered.
func Eprintln ¶
Eprintln formats using the default formats for its operands and writes to standard error output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func EscapeTrailingBackslash ¶
func FormatBlockMessage ¶
func GetLogLevel ¶
func GetLogLevel() int
func HasNativeColorSupport ¶
func HasNativeColorSupport(stream interface{}) bool
func HasPosixColorSupport ¶
func HasPosixColorSupport() bool
func IsCygwinTTY ¶
func IsInteractive ¶
func IsInteractive(stream interface{}) bool
func IsTerminal ¶
func IsTerminal(stream interface{}) bool
func Print ¶
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Printf ¶
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func Printfln ¶
Printfln formats according to a format specifier and writes to standard error output. A newline is appended. It returns the number of bytes written and any write error encountered.
func Println ¶
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Scan ¶
Scan scans text read from standard input, storing successive space-separated values into successive arguments. Newlines count as space. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why.
func Scanf ¶
Scanf scans text read from standard input, storing successive space-separated values into successive arguments as determined by the format. It returns the number of items successfully scanned. If that is less than the number of arguments, err will report why. Newlines in the input must match newlines in the format. The one exception: the verb %c always scans the next rune in the input, even if it is a space (or tab etc.) or newline.
func Scanln ¶
Scanln is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF.
func SetLogLevel ¶
func SymfonyStyle ¶
func SymfonyStyle(stdout *ConsoleOutput, stdin *Input) style
Types ¶
type ConsoleOutput ¶
func NewBufferedConsoleOutput ¶
func NewBufferedConsoleOutput(stdout, stderr io.Writer) *ConsoleOutput
func RemapOutput ¶
func RemapOutput(out, err io.Writer) *ConsoleOutput
func (ConsoleOutput) Fd ¶
func (cs ConsoleOutput) Fd() uintptr
func (ConsoleOutput) GetFormatter ¶
func (cs ConsoleOutput) GetFormatter() *Formatter
func (ConsoleOutput) SetDecorated ¶
func (cs ConsoleOutput) SetDecorated(decorated bool)
func (ConsoleOutput) SetFormatter ¶
func (cs ConsoleOutput) SetFormatter(formatter *Formatter)
type Cursor ¶
func (Cursor) ClearLineAfter ¶
ClearLine clears all the output from the current line after the current position.
func (Cursor) ClearOutput ¶
ClearOutput clears all the output from the cursors' current position to the end of the screen.
func (Cursor) ClearScreen ¶
ClearOutput clears the entire screen.
func (Cursor) MoveToColumn ¶
func (Cursor) MoveToPosition ¶
func (Cursor) RestorePosition ¶
func (Cursor) SavePosition ¶
type Formatter ¶
type Formatter struct { Decorated bool SupportsAdvancedDecoration bool // contains filtered or unexported fields }
func NewFormatter ¶
func NewFormatter() *Formatter
func (*Formatter) SetStyle ¶
func (formatter *Formatter) SetStyle(name string, style *FormatterStyle)
type FormatterStyle ¶
type FormatterStyle struct {
// contains filtered or unexported fields
}
func NewFormatterStyle ¶
func NewFormatterStyle(foreground, background string, options []string) *FormatterStyle
func (*FormatterStyle) GetHref ¶
func (style *FormatterStyle) GetHref() string
func (*FormatterStyle) SetHref ¶
func (style *FormatterStyle) SetHref(href string)
type Input ¶
type Input struct {
// contains filtered or unexported fields
}