completion

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const CompRequestCmd = "__complete"

CompRequestCmd Hidden command to request completion results from the program. Used by the shell completion script.

Variables

This section is empty.

Functions

func CompDebug

func CompDebug(msg string)

CompDebug prints the specified string to the same file as where the completion script prints its logs. Note that completion printouts should never be on stdout as they would be wrongly interpreted as actual completion choices by the completion script.

func CompDebugln

func CompDebugln(msg string)

CompDebugln prints the specified string with a newline at the end to the same file as where the completion script prints its logs. Such logs are only printed when the user has set the environment variable BASH_COMP_DEBUG_FILE to the path of some file to be used.

func CompError

func CompError(msg string)

CompError prints the specified completion message to stderr.

func CompErrorln

func CompErrorln(msg string)

CompErrorln prints the specified completion message to stderr with a newline at the end.

func GetBashCustomFunction

func GetBashCustomFunction() string

GetBashCustomFunction returns the bash code to handle custom go completion This should eventually be provided by Cobra

func NewCompleteCmd

func NewCompleteCmd(settings *cli.EnvSettings, out io.Writer) *cobra.Command

NewCompleteCmd add a special hidden command that an be used to request completions

func RegisterFlagCompletionFunc

func RegisterFlagCompletionFunc(flag *pflag.Flag, f func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective))

RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag

func RegisterValidArgsFunc

func RegisterValidArgsFunc(cmd *cobra.Command, f func(cmd *cobra.Command, args []string, toComplete string) ([]string, BashCompDirective))

RegisterValidArgsFunc should be called to register a function to provide argument completion for a command

Types

type BashCompDirective

type BashCompDirective int

BashCompDirective is a bit map representing the different behaviors the shell can be instructed to have once completions have been provided.

const (
	// BashCompDirectiveError indicates an error occurred and completions should be ignored.
	BashCompDirectiveError BashCompDirective = 1 << iota

	// BashCompDirectiveNoSpace indicates that the shell should not add a space
	// after the completion even if there is a single completion provided.
	BashCompDirectiveNoSpace

	// BashCompDirectiveNoFileComp indicates that the shell should not provide
	// file completion even when no completion is provided.
	// This currently does not work for zsh or bash < 4
	BashCompDirectiveNoFileComp

	// BashCompDirectiveDefault indicates to let the shell perform its default
	// behavior after completions have been provided.
	BashCompDirectiveDefault BashCompDirective = 0
)

Jump to

Keyboard shortcuts

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