Documentation
¶
Overview ¶
Package complete builds shell completion functions from local data: enum flags whose help text and completions come from one list, file and directory filters, and dynamic lists with a timeout.
Index ¶
- Constants
- func Assign(cs []Choice) cobra.CompletionFunc
- func Dirs() cobra.CompletionFunc
- func Dynamic(timeout time.Duration, src Source) cobra.CompletionFunc
- func DynamicList(timeout time.Duration, src Source) cobra.CompletionFunc
- func Enum(cs []Choice) cobra.CompletionFunc
- func Files(exts ...string) cobra.CompletionFunc
- func IsRequest(cmd *cobra.Command) bool
- func Join(cs []Choice) string
- func List(cs []Choice) cobra.CompletionFunc
- func NoFiles(*cobra.Command, []string, string) ([]cobra.Completion, cobra.ShellCompDirective)
- func Usage(text string, cs []Choice) string
- func Values(cs []Choice) []string
- type Choice
- type ConfigTools
- type Source
Constants ¶
const Timeout = time.Second
Timeout is how long a dynamic completion may take before it gives up.
Variables ¶
This section is empty.
Functions ¶
func Assign ¶
func Assign(cs []Choice) cobra.CompletionFunc
Assign returns a completion function for key=path values such as --out json=report.json. It offers each value of cs followed by "=", and file names once the key is typed.
func Dirs ¶
func Dirs() cobra.CompletionFunc
Dirs returns a completion function for directory names.
func Dynamic ¶
func Dynamic(timeout time.Duration, src Source) cobra.CompletionFunc
Dynamic returns a completion function that offers what src lists, filtered by prefix. When src fails or takes longer than timeout, it offers nothing and returns ShellCompDirectiveError.
func DynamicList ¶
func DynamicList(timeout time.Duration, src Source) cobra.CompletionFunc
DynamicList is Dynamic for a comma-separated list, completing the last element like List.
func Enum ¶
func Enum(cs []Choice) cobra.CompletionFunc
Enum returns a completion function that offers cs with descriptions and no file names.
func Files ¶
func Files(exts ...string) cobra.CompletionFunc
Files returns a completion function for file names with one of exts (without the dot), or any file when exts is empty. fish and PowerShell ignore the filter and list every file.
func IsRequest ¶
IsRequest reports whether cmd answers a completion request (cobra's __complete or carapace's _carapace) instead of running a command.
func List ¶
func List(cs []Choice) cobra.CompletionFunc
List returns a completion function for a comma-separated list of cs values. It completes the last element, keeps the ones before it and leaves out values already in the list.
func NoFiles ¶
func NoFiles(*cobra.Command, []string, string) ([]cobra.Completion, cobra.ShellCompDirective)
NoFiles is a completion function for free-form values: it offers nothing, not even file names.
Types ¶
type ConfigTools ¶
ConfigTools returns the tools and aliases of the user's config files.
type Source ¶
Source lists choices from local data. cmd gives access to the flags parsed so far.
func Tools ¶
func Tools(cfg ConfigTools) Source
Tools lists the tool names of the embedded relgap registry, the config and the embedded mise registry snapshot, with their repositories as descriptions. It never runs mise or calls GitHub.