xpflag

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

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

func NewFunc

func NewFunc(parse func(string) error) *Func

func (*Func) Set

func (o *Func) Set(value string) error

Set implements pflag.Value.

func (*Func) String

func (o *Func) String() string

String implements pflag.Value.

func (*Func) Type

func (o *Func) Type() string

Type implements pflag.Value.

type OneOf

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

func NewOneOf

func NewOneOf(defaul string, allowed ...string) *OneOf

func (*OneOf) Complete

func (o *OneOf) Complete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

Allow to use OneOf flags in the cobra autocompletion framework. For example:

loglevel := xpflag.New("info", "debug", "info", "warn", "error") cmd.Flags().Var(loglevel, "log-level", "log level, one of "+loglevel.Variants()) cmd.RegisterFlagCompletionFunc(flagName, loglevel.Complete)

func (*OneOf) Set

func (o *OneOf) Set(value string) error

Set implements pflag.Value.

func (*OneOf) String

func (o *OneOf) String() string

String implements pflag.Value.

func (*OneOf) Type

func (o *OneOf) Type() string

Type implements pflag.Value.

func (*OneOf) Variants

func (o *OneOf) Variants() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳