entrypoint

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 12 Imported by: 31

Documentation

Index

Constants

View Source
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

View Source
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

View Source
var HelpTextLineWidth = 80

Override this to have custom line widths

Functions

func EnvironmentVarRequiredE

func EnvironmentVarRequiredE(varName string) (string, error)

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

func HelpTableAwareDetermineIndent(text string, tableDelimiterRe string) string

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

func IndentAwareWrapText(text string, lineWidth int, indent string) string

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 NewApp

func NewApp() *cli.App

Wrapper around cli.NewApp that sets the help text printer.

func NewRequiredArgsError

func NewRequiredArgsError(message string) error

func PrefixedFirstFlagName

func PrefixedFirstFlagName(fullName string) string

func RegexpSplitAfter

func RegexpSplitAfter(re *regexp.Regexp, str string) []string

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

func StringFlagRequiredE(cliContext *cli.Context, flagName string) (string, error)

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 TabAwareStringLength(text string, tabLength int) int

func WrappedHelpPrinter

func WrappedHelpPrinter(out io.Writer, templateString string, data interface{})

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

Jump to

Keyboard shortcuts

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