Documentation
¶
Index ¶
- Variables
- func PrettyJSON(data interface{}) (string, error)
- type App
- func (a *App) CheckStrictEnv() error
- func (a *App) Command(name, help string) *CommandClause
- func (a *App) ExtraEnvVarFunc(f func(key string) bool) *App
- func (a *App) Flag(name, help string) *Flag
- func (a *App) PrintEnv(w io.Writer, verbose bool, osEnv func() []string) error
- func (a *App) Version(version string) *App
- type CommandClause
- type Flag
- type Logger
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultEnvSeparator defines how to join env var names. DefaultEnvSeparator = "_" // DefaultCommandDelimiters defines which delimiters should be replaced. DefaultCommandDelimiters = []string{" ", "-"} )
Functions ¶
func PrettyJSON ¶
PrettyJSON returns a 4-space indented JSON text. Can be useful for printing out structs.
Types ¶
type App ¶
type App struct { *kingpin.Application // contains filtered or unexported fields }
App represents a command-line application that wraps the kingpin library and adds additional functionality.
func (*App) CheckStrictEnv ¶ added in v0.34.0
CheckStrictEnv checks that every environment variable that starts with the app name is recognized by the application.
func (*App) Command ¶
func (a *App) Command(name, help string) *CommandClause
Command defines a new top-level command with the given name and help text.
func (*App) ExtraEnvVarFunc ¶ added in v0.24.0
ExtraEnvVarFunc takes a function that determines additional environment variables recognized by the application.
func (*App) Flag ¶
Flag defines a new flag with the given long name and help text, adding an environment variable default configurable by APP_FLAG_NAME.
func (*App) PrintEnv ¶
PrintEnv reads all environment variables starting with the app name and writes a table with the keys and their status: set, empty, unrecognized. The value of environment variables are not printed out for security reasons. The list is limited to variables that are actually set in the environment. Setting verbose to true will also include all known variables that are not set.
type CommandClause ¶
CommandClause represents a command clause in a command0-line application.
func (*CommandClause) Command ¶
func (cmd *CommandClause) Command(name, help string) *CommandClause
Command adds a new subcommand to this command.
func (*CommandClause) Flag ¶
func (cmd *CommandClause) Flag(name, help string) *Flag
Flag defines a new flag with the given long name and help text, adding an environment variable default configurable by APP_COMMAND_FLAG_NAME. The help text is suffixed with a description of secrthe environment variable default.
func (*CommandClause) Hidden ¶
func (cmd *CommandClause) Hidden() *CommandClause
Hidden hides the command in help texts.
type Flag ¶
type Flag struct { *kingpin.FlagClause // contains filtered or unexported fields }
Flag represents a command-line flag.
type Logger ¶
type Logger interface { // Debugf logs a message when debug mode is enabled. Debugf(format string, args ...interface{}) // Warningf logs a message when debug mode is enabled. Warningf(format string, args ...interface{}) // EnableDebug turns printing debug messages on. EnableDebug() }
Logger can be used to log debug and warning messages.
Directories
¶
Path | Synopsis |
---|---|
Package clip provides functionality to read from and write to the clipboard.
|
Package clip provides functionality to read from and write to the clipboard. |
fakeclip
Package fakeclip provides fake implementations of the clip.Clipper interface to be used for testing.
|
Package fakeclip provides fake implementations of the clip.Clipper interface to be used for testing. |
Package cloneproc provides functionality to spawn a detached clone of the current process.
|
Package cloneproc provides functionality to spawn a detached clone of the current process. |
Package filemode provides a wrapper around os.FileMode so that it can be parsed from a CLI flag.
|
Package filemode provides a wrapper around os.FileMode so that it can be parsed from a CLI flag. |
Package mlock allows for locking memory, providing implementations for different operating systems.
|
Package mlock allows for locking memory, providing implementations for different operating systems. |
Package progress provides a printer that writes dots at a configured interval.
|
Package progress provides a printer that writes dots at a configured interval. |
fakeprogress
Package fakeprogress provides an implementation of the progress.Printer interface to be used in tests.
|
Package fakeprogress provides an implementation of the progress.Printer interface to be used in tests. |
Package ui provides a simple way to interact with the user through the terminal, i.e.
|
Package ui provides a simple way to interact with the user through the terminal, i.e. |