Documentation ¶
Overview ¶
Package entrypoint contains helper functions for setting up a urfave/cli application that can be used as the CLI entrypoint.
Index ¶
- Constants
- Variables
- func EnvironmentVarRequiredE(varName string) (string, error)
- func HelpTableAwareDetermineIndent(text string, tableDelimiterRe string) string
- func IndentAwareWrapText(text string, lineWidth int, indent string) string
- func NewApp() *cli.App
- func NewRequiredArgsError(message string) error
- func PrefixedFirstFlagName(fullName string) string
- func RegexpSplitAfter(re *regexp.Regexp, str string) []string
- func RunApp(app *cli.App)
- func StringFlagRequiredE(cliContext *cli.Context, flagName string) (string, error)
- func TabAwareStringLength(text string, tabLength int) int
- func WrappedHelpPrinter(out io.Writer, templateString string, data interface{})
- type RequiredArgsError
Constants ¶
const CLI_APP_HELP_TEMPLATE = `` /* 438-byte string literal not displayed */
This version of the app help template has the following changes over the default ones: - Headers are title cased as opposed to all caps - NAME, VERSION, AUTHOR, COPYRIGHT, and GLOBAL OPTIONS sections are removed - Global options are displayed by name in the usage text
const CLI_COMMAND_HELP_TEMPLATE = `` /* 281-byte string literal not displayed */
This version of the command help template has the following changes over the default ones: - Headers are title cased as opposed to all caps - NAME and CATEGORY sections are removed
Variables ¶
var HelpTextLineWidth = 80
Override this to have custom line widths
Functions ¶
func EnvironmentVarRequiredE ¶
EnvironmentVarRequiredE checks if a required environment variable is set. This will return the environment variable value, or an error if the environment variable is not set.
func HelpTableAwareDetermineIndent ¶
Determine the indent string, accounting for textual tables. Assumes only two columns, and there is a clear delimiter for them, like in help text.
func IndentAwareWrapText ¶
Wrap text to line width, while preserving any indentation Examples: in: text = ` exec\tExecute a command with temporary AWS credentials obtained by logging into Gruntwork Houston` lineWidth = 80 indent = ` \t` out:
exec\tExecute a command with temporary AWS credentials obtained by \tlogging into Gruntwork Houston
func NewRequiredArgsError ¶
func PrefixedFirstFlagName ¶
func RegexpSplitAfter ¶
regexp version of strings.SplitAfter. Similar functionality to regexp.Split, but returns the delimited strings with the trailing delimiter appended to it. Example:
re := regexp.MustCompile(`\s+`) text := "one two three" out := RegexpSplitAfter(re, text) out == ["one ", "two ", "three"]
func RunApp ¶
func RunApp(app *cli.App)
Run the given app, handling errors, panics, and stack traces where possible
func StringFlagRequiredE ¶
StringFlagRequiredE checks if a required string flag is passed in on the CLI. This will return the set string, or an error if the flag is not passed in.
func TabAwareStringLength ¶
func WrappedHelpPrinter ¶
HelpPrinter that will wrap the text at HELP_TEXT_LINE_WIDTH characters, while preserving indentation and table tabs. Currently only works with tables delimited by `\t` and with only 2 columns.
Types ¶
type RequiredArgsError ¶
type RequiredArgsError struct {
// contains filtered or unexported fields
}
func (RequiredArgsError) Error ¶
func (err RequiredArgsError) Error() string