cmpl

package
v1.38.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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

func SuggestNothing() func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

SuggestNothing returns a function that provides no suggestions.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL