suggestions

package
v1.1.20210707 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Path     = "path"
	Output   = "output"
	Loglevel = "Loglevel"
)
View Source
const (
	Option   = "option"
	Argument = "argument"
)

Variables

This section is empty.

Functions

func BestEffortFilter

func BestEffortFilter(args []string, suggestions map[string][]prompt.Suggest) []prompt.Suggest

The BestEffortFilter is to find mostly match suggestion, common use for Options eg: input: istio admin log <POD_NAME> <POD_NAME2> --Options "istio admin log"'s option is better than "istio admin"

func LengthFilter

func LengthFilter(args []string, suggestions map[string][]prompt.Suggest) []prompt.Suggest

The LengthFilter must make sure the each Arguments is in the right place, common use for Arguments eg: input: istio admin log <sth> only "istio admin log <sth>" will match

func RegisterSharedProvider

func RegisterSharedProvider(id string, provider Provider)

Types

type Completer

type Completer interface {
	Complete(doc prompt.Document) []prompt.Suggest
}

The Completer interface is a collection of functions for the user to perform intelligent completion when entering the command line

type GenericCompleter

type GenericCompleter struct {
	Completer
	SuggestionProviders Repository
	Arguments           []prompt.Suggest
	Options             []prompt.Suggest
	Setup               func(*GenericCompleter)
}

The GenericCompleter is not related to specific environmental Completer generalization achieved. When designing a Completer of a specific environment, general capabilities can be obtained by inheriting GenericCompleter.

func NewGenericCompleter

func NewGenericCompleter(arguments []prompt.Suggest, options []prompt.Suggest, setup func(*GenericCompleter)) *GenericCompleter

Construct a GenericCompleter instance

func (GenericCompleter) Complete

func (g GenericCompleter) Complete(doc prompt.Document) []prompt.Suggest

According to the user input information, give intelligent completion

type Provider

type Provider func(...string) []prompt.Suggest

The Provider is data source for different types of Suggestions

func BuildFixedSelectionProvider

func BuildFixedSelectionProvider(selections ...string) Provider

Build fixed selection (eg: json|yaml|xml) Provider

func BuildStaticCompletionProvider

func BuildStaticCompletionProvider(options []prompt.Suggest, fn SuggestionFilter) Provider

Build static completion (Arguments \ Options) Provider

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

The Repository is a set of Provider

func (*Repository) Add

func (r *Repository) Add(id string, provider Provider)

Adding a Provider to Repository

func (*Repository) Provide

func (r *Repository) Provide(id string, args ...string) []prompt.Suggest

Providing suggestion by a specified Provider

type SuggestionFilter

type SuggestionFilter func([]string, map[string][]prompt.Suggest) []prompt.Suggest

The SuggestionFilter determines how to map user input information to Suggestion

Jump to

Keyboard shortcuts

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