Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DynamicCommand ¶
type DynamicCommands ¶
type DynamicCommands map[string]DynamicCommand
func (DynamicCommands) Predictors ¶
func (cmds DynamicCommands) Predictors() map[string]complete.Predictor
type InputEnvVar ¶ added in v1.4.0
type InputEnvVar string
InputEnvVar Name of environment variables the caller can provide to influence the script. It's needed for configuration that needs to be passed from outside of the Go program. Parameters, to which Go program has no reasonable access. These parameters are meant to be generated by a script wrapper (usually in bash), or the script shebang line.
const ( // APP_CWD actual current directory from the perspective of the user. This info is needed because when script is run using // 'go run' command, the current directory may be messed up APP_CWD InputEnvVar = "APP_CWD" // APP_ARG_0 actual argument 0 - file path the user provided to run the script APP_ARG_0 InputEnvVar = "APP_ARG_0" // APP_SCRIPTPATH path to the script you want to use for subsequent runs (used for example to generate alias in // --install-completions command). Defaults to absolute version of APP_ARG_0 APP_SCRIPTPATH InputEnvVar = "APP_SCRIPTPATH" )
type InstallCompletions ¶
type InstallCompletions bool
func (InstallCompletions) BeforeReset ¶
func (f InstallCompletions) BeforeReset(script Script) error
type Options ¶
type Options struct { // command line options specification, as accepted by kong library CLI interface{} Description string DynamicCommands DynamicCommands // additional structs for CLI, they will be merged with CLI Plugins Plugins // map of variables you can use in a subset of CLI / Plugins tags (default, enum, help) in the form of ${varName} Vars Vars // Writers change stdout and stderr targets. Useful for testing. Writers Writers // ExitFunc custom "exit program in case of parsing error" function. Default os.Exit. Useful for testing ExitFunc func(code int) // Used for predicting script args in terminal. // map of predictor-name -> predictor. To use them, include `predictor:"name"` in kong struct field tag. // Check kongplete README for info Predictors map[string]complete.Predictor // contains filtered or unexported fields }
Options See defaultOptions for defaults
func (*Options) BindToInterface ¶ added in v1.10.0
This is the only way to be able to use interface arguments in command Run(args). `RunCommand(someStruct)` works only if the the command `Run(arg)` method has arg of `someStruct` type specifically, not an interface which `someStruct` implements.
use it like this:
BindToInterface(&interfaceImplementation, (*InterfaceType)(nil))
func (Options) GetDefaults ¶ added in v1.10.0
type Script ¶
type Script interface { // Dir directory where *.go script (with main() method) is located. Absolute path Dir() string // ScriptFileName filename of *.go script (with main() method) ScriptFileName() string // ScriptAlias returns script alias that is used as app name in help text, and also installed by GetInstallCompletionsScript // as an alias user can run and receive completions ScriptAlias() string // Cwd directory from where go script was called Cwd() string // RunCommand run command selected by Kong CLI based on command line arguments RunCommand(context ...any) error // GetInstallCompletionsScript returns script lines you can execute in bash, or put in .bashrc file to have an alias, and autocompletions for // this script GetInstallCompletionsScript() string // PrintUsage print usage - specific for app arguments provided PrintUsage() // PrintAppUsageAndExit print usage and exit - not specific to arguments provided - just like running 'app --help' PrintAppUsageAndExit() }
func InitCustom ¶
Click to show internal directories.
Click to hide internal directories.