chars

package
v1.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CharTab    = '\t'
	CharLF     = '\n'
	CharCR     = '\r'
	CharSpace  = ' '
	CharDash   = '-'
	CharEquals = '='
)
View Source
const (
	StrDash       = "-"
	StrEquals     = "="
	StrEmpty      = ""
	StrDoubleDash = "--"
	StrLF         = "\n"
)
View Source
const (
	FlagDivider    = " | "
	ParagraphBreak = "\n\n"
)
View Source
const DefaultGroupName = "174b9e831dec431181e31ede822bb3b5"

Variables

View Source
var DescriptionPadding = [...]string{
	"    ",
	"      ",
	"        ",
	"          ",
}
View Source
var HeaderPadding = [...]string{
	"",
	"  ",
	"    ",
	"      ",
}
View Source
var HelpTextMaxWidth = 100
View Source
var SubLinePadding = [...]string{
	"  ",
	"    ",
	"      ",
	"        ",
}

Functions

func IsAlpha

func IsAlpha(c byte) bool

func IsAlphanumeric

func IsAlphanumeric(c byte) bool

func IsBlank

func IsBlank(s string) bool

func IsBreakChar

func IsBreakChar(b byte) bool

func IsFlagStringSafe

func IsFlagStringSafe(c byte) bool

func IsHex added in v1.2.1

func IsHex(c byte) bool

func IsHexString added in v1.2.1

func IsHexString(s string) bool

func IsNumeric

func IsNumeric(c byte) bool

func IsOctal added in v1.2.1

func IsOctal(c byte) bool

func IsOctalString added in v1.2.1

func IsOctalString(s string) bool

func IsWhitespace

func IsWhitespace(c byte) bool

func NextEquals

func NextEquals(s string) int

func NextWhitespace

func NextWhitespace(s string) int

func Pad

func Pad(size int, out *bufio.Writer) error

func ValidateCommandNodeName

func ValidateCommandNodeName(name string) error

Types

type Break

type Break = [2]int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL