Documentation
¶
Overview ¶
Package komplete is a package for generating completions for Kong CLIs.
To use it, build a Kong parser from your CLI grammar, and then call Run with it to run the completion logic. This will automatically determine if the CLI is being invoked as a completion script or as a regular command.
parser, err := kong.New(cli) // ... komplete.Run(parser)
Command is provided as a convenient subcommand for generating completion scripts for various shells.
Custom logic to predict values for flags and arguments can be provided through WithPredictor. Install a predictor with a name, and refer to it in your CLI grammar with the `predictor:"name"` tag.
type CLI struct { Name string `help:"Name of the branch" predictor:"branches"` // ... } // ... komplete.Run(parser, komplete.WithPredictor("branches", branchesPredictor), // ... )
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct {
Shell string ` enum:"bash,zsh,fish" arg:"" required:"" help:"Shell to generate completions for."`
}
Command is the command to run to generate the completion script. It is intended to be used as a subcommand of the main CLI.
type Option ¶
type Option func(*options)
Option customizes completion logic.
func WithPredictor ¶
WithPredictor adds a named predictor to the completion logic.
Flags and arguments can request a predictor for their values by adding a `predictor:"name"` tag to the field.
type CLI struct { Name string `help:"Name of the branch" predictor:"branches"` // ... } komplete.Run(parser, komplete.WithPredictor("branches", branchesPredictor), )
func WithTransformCompleted ¶
WithTransformCompleted allows modifying the list of completed arguments, allowing replication of any os.Args transformations.