Documentation
¶
Index ¶
- func SuggestArgs(...) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func SuggestCandidates(cs ...string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func SuggestCandidatesCtx(cf func(*cobra.Command, []string) []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func SuggestCandidatesF(cf func() []string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
- func SuggestNothing() func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SuggestArgs ¶
func SuggestArgs( vfs ...func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective), ) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
SuggestArgs returns a function that uses the slice of valid argument functions vfs to provide completion suggestions for the passed command line arguments.
The selection of the respective entry in vfs is positional, i.e. to determine the suggestions for the fourth command line argument SuggestArgs calls the function at vfs[4] if it exists. To skip suggestions for an argument in the middle of a list of arguments pass either nil or SuggestNothing. Using SuggestNothing is preferred.
func SuggestCandidates ¶
func SuggestCandidates(cs ...string) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
SuggestCandidates returns a function that selects all items from the list of candidates cs which have the prefix toComplete. If toComplete is empty cs is returned.
The returned function is mainly intended to be passed to cobra/Command.RegisterFlagCompletionFunc or assigned to cobra/Command.ValidArgsFunction.
func SuggestCandidatesCtx ¶
func SuggestCandidatesCtx( cf func(*cobra.Command, []string) []string, ) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
SuggestCandidatesCtx returns a function that uses the candidate function cf to obtain a list of completion candidates in the context of previously selected arguments and flags. This is mainly useful for completion candidates that depend on a previously selected item like a server.
Once the list of candidates is obtained the function returned by SuggestCandidatesF behaves like the function returned by SuggestCandidates.
func SuggestCandidatesF ¶
func SuggestCandidatesF( cf func() []string, ) func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)
SuggestCandidatesF returns a function that calls the candidate function cf to obtain a list of completion candidates. Once the list of candidates is obtained the function returned by SuggestCandidatesF behaves like the function returned by SuggestCandidates.
func SuggestNothing ¶
SuggestNothing returns a function that provides no suggestions.
Types ¶
This section is empty.