Documentation
¶
Overview ¶
Package str manipulates strings and standard output text.
Index ¶
- Constants
- Variables
- func Alert() string
- func Bool(b bool) string
- func Border(s string) *bytes.Buffer
- func Center(width int, s string) string
- func ColCmt(s string) string
- func ColFuz(s string) string
- func ColInf(s string) string
- func ColPri(s string) string
- func ColSec(s string) string
- func ColSuc(s string) string
- func Confirm() string
- func Default(s, val string) string
- func Example(s string) string
- func GetEnv(key string) string
- func HR(width int) string
- func HRPad(width int) string
- func Head(width int, s string) string
- func HeadDark(width int, s string) string
- func Highlight(source, lexer, style string, ansi bool) error
- func HighlightWriter(w io.Writer, source, lexer, style string, ansi bool) error
- func Info() string
- func Italic(s string) string
- func JSONStyles(cmd string) string
- func NumberizeKeys(keys ...string) string
- func Options(s string, shorthand, flagHelp bool, opts ...string) string
- func Path(s string) string
- func Required(s string) string
- func Term(colorEnv, env string) string
- func UnderlineChar(c string) (string, error)
- func UnderlineKeys(keys ...string) string
- func Valid(style string) bool
- type JSONExample
Examples ¶
Constants ¶
const ( // TermMono no color. TermMono terminal = iota // Term16 ANSI standard 16 color. Term16 // Term88 XTerm 88 color. Term88 // Term256 XTerm 256 color. Term256 // Term16M ANSI high-color. Term16M // HBar is a the Unicode horizontal bar character. HBar = "\u2500" )
Variables ¶
var ErrRune = errors.New("invalid encoded rune")
Functions ¶
func Alert ¶
func Alert() string
Alert prints "Problem" using the Error color.
Example ¶
Output: Problem:
func Border ¶
Border wraps the string around a single line border.
Example ¶
Output: ┌────┐ │ hi │ └────┘
func Confirm ¶ added in v0.0.33
func Confirm() string
Confirm prints the "Confirm" string using the Question color.
func Default ¶
Default appends (default ...) to the usage string.
Example ¶
Output: hi, bye (default "hi")
func GetEnv ¶ added in v0.0.31
GetEnv gets and formats the value of the environment variable named in the key.
func Head ¶ added in v0.0.33
Head returns a colored and underlined string for use as a header. Provide a fixed width value for the underline border or set to zero.
func HighlightWriter ¶
HighlightWriter writes the highlight syntax of the source string except when piped to stdout.
func Info ¶
func Info() string
Info prints "Information" using the Info color.
Example ¶
Output: Information:
func JSONStyles ¶
JSONStyles prints out a list of available YAML color styles.
func NumberizeKeys ¶
NumberizeKeys uses ANSI to underline and prefix a sequential number in front of each key.
func Options ¶
Options appends options: ... to the usage string.
Example ¶
Output: this is an example of a list of options. Options: option1, option2, option3
func Term ¶
Term determines the terminal type based on the COLORTERM and TERM environment variables.
func UnderlineChar ¶
UnderlineChar uses ANSI to underline the first character of a string.
func UnderlineKeys ¶
UnderlineKeys uses ANSI to underline the first letter of each key.
Types ¶
type JSONExample ¶
type JSONExample struct { Style struct { Name string `json:"name"` Count int `json:"count"` Default bool `json:"default"` } }
JSONExample is used to preview theme colors.
func (JSONExample) String ¶
func (s JSONExample) String(flag string) string