Documentation
¶
Index ¶
- func AppFrom(cmd *cli.Command, version string) *cli.App
- func Dedent(s string) string
- func HelpFmt(s string) string
- func ReqArgCount(c *cli.Context, required_arg_count int) error
- func Wrap(str string, wrapLength int) string
- func WrapCustom(str string, wrapLength int, newLineStr string, wrapLongWords bool) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HelpFmt ¶
HelpFmt handles formatting help output for things such as descriptions.
1. Shared indentation in the help string that may occur from tabbed code is dedented. 2. Leading and trailing whitespace is trimmed. 3. Text is wrapped at 80 characters for that "book-like" feel.
func ReqArgCount ¶
ReqArgCount is a helper function for urfave/cli/v2 It is used as an alias to check if a required number of arguments is passed to the command via the cli context.
The reason to use this is to standardize the exit code as well as the error output. Having the common string in one place is better than manually writing this small condition and string many times across a code-base.
func Wrap ¶
Wrap wraps a single line of text, identifying words by ' '. New lines will be separated by '\n'. Very long words, such as URLs will not be wrapped. Leading spaces on a new line are stripped. Trailing spaces are not stripped.
Parameters:
str - the string to be word wrapped wrapLength - the column (a column can fit only one character) to wrap the words at, less than 1 is treated as 1
Returns:
a line with newlines inserted
Original source: https://github.com/Masterminds/goutils/blob/f1923532a168b8203bfe956d8cd3b17ebece5982/wordutils.go#L71-L73
func WrapCustom ¶
WrapCustom wraps a single line of text, identifying words by ' '. Leading spaces on a new line are stripped. Trailing spaces are not stripped.
Parameters:
str - the string to be word wrapped wrapLength - the column number (a column can fit only one character) to wrap the words at, less than 1 is treated as 1 newLineStr - the string to insert for a new line, "" uses '\n' wrapLongWords - true if long words (such as URLs) should be wrapped
Returns:
a line with newlines inserted
Original source: https://github.com/Masterminds/goutils/blob/f1923532a168b8203bfe956d8cd3b17ebece5982/wordutils.go#L88-L150
Types ¶
This section is empty.