cmdcompl

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFixedSuggestionsToFlag

func AddFixedSuggestionsToFlag(cmd *cobra.Command, flagName string, va ValidArgs) error

AddFixedSuggestionsToFlag add fixed suggestions to a flag

func AddSuggestionsToFlag

func AddSuggestionsToFlag(cmd *cobra.Command, flagName string, suggestFn SuggestFn) error

AddSuggestionsToFlag add fixed suggestions to a flag

func CombineSuggestionsToArgs

func CombineSuggestionsToArgs(fns ...SuggestFn) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

CombineSuggestionsToArgs combine one or more suggestion resolver functions and call then accordingly with arg count

Types

type SuggestFn

type SuggestFn func(cmd *cobra.Command, args []string, toComplete string) (ValidArgs, error)

SuggestFn is a function to search valid suggestions for a flag/argument

type ValidArgs

type ValidArgs interface {
	// IntoUse will return a string with a complete arg use
	// Example: "{ arg1 | arg2 | arg3 }"
	IntoUse() string
	// IntoUse will return a string with the joined options
	// Example: "arg1 | arg2 | arg3"
	IntoUseOptions() string
	// OnlyArgs will return a []string to be used on cobra.Command.ValidArgs
	OnlyArgs() []string
	// OnlyArgs will return a []string to be used as result for auto-complete
	IntoValidArgs() []string
}

func EmptySuggestionFuncion

func EmptySuggestionFuncion(_ *cobra.Command, _ []string, _ string) (ValidArgs, error)

func EmptyValidArgs

func EmptyValidArgs() ValidArgs

EmptyValidArgs returns a ValidArgs with no options

type ValidArgsMap

type ValidArgsMap map[string]string

func (ValidArgsMap) IntoUse

func (va ValidArgsMap) IntoUse() string

func (ValidArgsMap) IntoUseOptions

func (va ValidArgsMap) IntoUseOptions() string

func (ValidArgsMap) IntoValidArgs

func (va ValidArgsMap) IntoValidArgs() []string

func (ValidArgsMap) Long

func (va ValidArgsMap) Long() string

func (ValidArgsMap) OnlyArgs

func (va ValidArgsMap) OnlyArgs() []string

func (ValidArgsMap) Set

func (va ValidArgsMap) Set(k, v string) ValidArgsMap

type ValidArgsSlide

type ValidArgsSlide []string

func (ValidArgsSlide) IntoUse

func (va ValidArgsSlide) IntoUse() string

func (ValidArgsSlide) IntoUseOptions

func (va ValidArgsSlide) IntoUseOptions() string

func (ValidArgsSlide) IntoValidArgs

func (va ValidArgsSlide) IntoValidArgs() []string

func (ValidArgsSlide) OnlyArgs

func (va ValidArgsSlide) OnlyArgs() []string

Jump to

Keyboard shortcuts

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