Documentation ¶
Index ¶
- Constants
- Variables
- func IsAlpha(c byte) bool
- func IsAlphanumeric(c byte) bool
- func IsBlank(s string) bool
- func IsBreakChar(b byte) bool
- func IsFlagStringSafe(c byte) bool
- func IsNumeric(c byte) bool
- func IsWhitespace(c byte) bool
- func NextEquals(s string) int
- func NextWhitespace(s string) int
- func Pad(size int, out *bufio.Writer) error
- func ValidateCommandNodeName(name string) error
- type Break
- type DescriptionFormatter
- func (this *DescriptionFormatter) BreakFormatSplitWord(word string) error
- func (this *DescriptionFormatter) BreakFormatTypeBreak(last, current *segment) error
- func (this *DescriptionFormatter) BreakFormatTypeLineBreak(last, current *segment) error
- func (this *DescriptionFormatter) BreakFormatTypeWord(last, current *segment) error
- func (this *DescriptionFormatter) Format(text string) error
Constants ¶
const ( CharTab = '\t' CharLF = '\n' CharCR = '\r' CharSpace = ' ' CharDash = '-' CharEquals = '=' )
const ( StrDash = "-" StrEquals = "=" StrEmpty = "" StrDoubleDash = "--" StrLF = "\n" )
const ( FlagDivider = " | " ParagraphBreak = "\n\n" )
const DefaultGroupName = "174b9e831dec431181e31ede822bb3b5"
Variables ¶
var DescriptionPadding = [...]string{
" ",
" ",
" ",
" ",
}
var HeaderPadding = [...]string{
"",
" ",
" ",
" ",
}
var HelpTextMaxWidth = 100
var SubLinePadding = [...]string{
" ",
" ",
" ",
" ",
}
Functions ¶
func IsAlphanumeric ¶
func IsBreakChar ¶
func IsFlagStringSafe ¶
func IsWhitespace ¶
func NextEquals ¶
func NextWhitespace ¶
func ValidateCommandNodeName ¶
Types ¶
type DescriptionFormatter ¶
type DescriptionFormatter struct {
// contains filtered or unexported fields
}
DescriptionFormatter is a type that may be used to format a CLI element description by breaking it down to fit into the allowed maximum line width.
func NewDescriptionFormatter ¶
func NewDescriptionFormatter( prefixPadding string, maxTotalWidth int, writer *bufio.Writer, ) DescriptionFormatter
NewDescriptionFormatter returns a configured DescriptionFormatter instance.
func (*DescriptionFormatter) BreakFormatSplitWord ¶
func (this *DescriptionFormatter) BreakFormatSplitWord(word string) error
BreakFormatSplitWord splits the given word to fit onto the line if necessary.
If the word can fit onto the line without breaking, then it will be written.
If the word is long enough that it needs to be split to fit onto the line, it will be split. It will be split as many times as necessary to write it out while keeping in the max line width.
The `curWidth` variable will be updated with the current width of the line after writing is completed.
func (*DescriptionFormatter) BreakFormatTypeBreak ¶
func (this *DescriptionFormatter) BreakFormatTypeBreak(last, current *segment) error
func (*DescriptionFormatter) BreakFormatTypeLineBreak ¶
func (this *DescriptionFormatter) BreakFormatTypeLineBreak(last, current *segment) error
func (*DescriptionFormatter) BreakFormatTypeWord ¶
func (this *DescriptionFormatter) BreakFormatTypeWord(last, current *segment) error
func (*DescriptionFormatter) Format ¶
func (this *DescriptionFormatter) Format(text string) error
Format is the standard entrypoint for the description formatter.
It takes a description string and formats it to fit within the configured maximum line length.