Documentation
¶
Overview ¶
package hobocode provides some lazy convenience functions for wrapping text in colors, detecting tty, terminal size, and colored/formatted interactive inputs
The coloring choices are opinionated and the "levels" are based on common logging patterns but with a focus on Console UX vs. logging style
Note: Most of the printers in this library automatically new-line fields with Println variants
Index ¶
- func Colorable(pipe *os.File) bool
- func Confirm(message string) bool
- func Confirmf(format string, a ...interface{}) bool
- func Debug(message string)
- func Debugf(format string, a ...interface{})
- func Error(message string)
- func Errorf(format string, a ...interface{})
- func Ficolor(indent int, fd *os.File, color text.Color, format string, a ...interface{})
- func Ficolorf(indent int, fd *os.File, color text.Color, format string, a ...interface{})
- func Header(title string)
- func HeaderLeft(title string)
- func Icolor(indent int, fd *os.File, color text.Color, message string)
- func Icolorf(indent int, fd *os.File, color text.Color, format string, a ...interface{})
- func Idebug(indent int, message string)
- func Idebugf(indent int, format string, a ...interface{})
- func Ierror(indent int, message string)
- func Ierrorf(indent int, format string, a ...interface{})
- func Iinfo(indent int, message string)
- func Iinfof(indent int, format string, a ...interface{})
- func Info(message string)
- func Infof(format string, a ...interface{})
- func Input(message string) string
- func Inputd(defaultOption string, message string) string
- func Inputf(format string, a ...interface{}) string
- func Isuccess(indent int, message string)
- func Isuccessf(indent int, format string, a ...interface{})
- func Iwarn(indent int, message string)
- func Iwarnf(indent int, format string, a ...interface{})
- func Selection(options []string, message string, prompt string) int
- func Selectionr(options []string, recommendedOption int, message string, prompt string) int
- func Size(pipe *os.File) (int, int, error)
- func Std(fd *os.File, message string)
- func Stderr(message string)
- func Stderrln(message string)
- func Stdlin(fd *os.File, message string)
- func Stdout(message string)
- func Stdoutln(message string)
- func Success(message string)
- func Successf(format string, a ...interface{})
- func Tindent(n int) string
- func Warn(message string)
- func Warnf(format string, a ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Colorable ¶
Colorable reports if the given *os.File is a terminal or not (os.Stdout, os.Stderr)
func Confirm ¶
Confirm is a naive confirmation prompt in HiRed that won't break until an explicit answer is given
func Confirmf ¶
Confirmf is a naive confirmation prompt in HiRed that won't break until an affirmative answer is given (with a formatted message)
func Debug ¶
func Debug(message string)
Debug prints the given message with bright green if Colorable
Stdout
func Debugf ¶
func Debugf(format string, a ...interface{})
Debugf prints the given formatted message with bright green if Colorable
Stdout
func Error ¶
func Error(message string)
Error prints the given message with bright red if Colorable
Stderr
func Errorf ¶
func Errorf(format string, a ...interface{})
Errorf prints the given formatted message with bright red if Colorable
Stderr
func Ficolor ¶ added in v0.2.0
Ficolor prints the given string at the given indent to the given os.File with the given text.Color, if colorable and does not newline
func Ficolorf ¶ added in v0.2.0
Ficolorf prints the given format at the given indent to the given os.File with the given text.Color, if colorable and does not newline
func Header ¶
func Header(title string)
Header prints a header title wrapped by "=" characters sized to the terminal width
Stdout
func HeaderLeft ¶
func HeaderLeft(title string)
HeaderLeft prints a header title offset to the left wrapped by "=" characters sized to the terminal width
Stdout
func Icolor ¶
Icolor prints the given string at the given indent to the given os.File with the given text.Color, if colorable with newline
func Icolorf ¶
Icolorf prints the given format at the given indent to the given os.File with the given text.Color, if colorable with newline
func Idebugf ¶
Idebugf prints the given formatted message with bright green if Colorable with an indent
Stdout
func Ierrorf ¶
Ierrorf prints the given formatted message with bright red if Colorable and an indent
Stderr
func Iinfof ¶
Iinfof prints the given formatted message with bright cyan if Colorable and an indent
Stdout
func Info ¶
func Info(message string)
Info prints the given message with bright cyan if Colorable
Stdout
func Infof ¶
func Infof(format string, a ...interface{})
Infof prints the given formatted message with bright cyan if colorable
Stdout
func Inputd ¶ added in v0.2.0
Inputd acquires user CLI input with a default defaultOption is presented as the default and used on nil entry
func Inputf ¶
Inputf acquires user CLI input using a formatted message defaultOption is presented as the default and used on nil entry
func Isuccess ¶
Isuccess prints the given message with bright green if Colorable with an indent
Stdout
func Isuccessf ¶
Isuccessf prints the given formatted message with bright green if Colorable with an indent
Stdout
func Iwarnf ¶
Iwarnf prints the given formatted message with bright yellow if Colorable and an indent
Stderr
func Selection ¶ added in v0.2.0
Select allows the user to select from a list of options the index of the options is used as the selection and the user selection is returned as that int a response of -1 indicates a failure to capture input message introduces the list selection prompt is the input line
func Selectionr ¶ added in v0.2.0
Selectr allows the user to select from a list of options with a recommended option the index of the options is used as the selection and the user selection is returned as that int a response of -1 indicates a failure to capture input message introduces the list selection prompt is the input line
func Stderr ¶ added in v0.2.0
func Stderr(message string)
Stderr prints without newline to os.Stdout
func Stdout ¶ added in v0.2.0
func Stdout(message string)
Stdout prints without newline to os.Stdout
func Success ¶
func Success(message string)
Success prints the given message with bright green if Colorable
Stdout
func Successf ¶
func Successf(format string, a ...interface{})
Successf prints the given formatted message with bright green if Colorable
Stdout
Types ¶
This section is empty.