ui

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIgnoreValue = errors.New("ignore value")

Functions

func PositionalArgs

func PositionalArgs(aargs []RequiredArg, preHook func(cmd *cobra.Command)) cobra.PositionalArgs

func PromptUiConfirmFunc

func PromptUiConfirmFunc(label string, defaultValue bool) func(validator types.Validator[bool]) (bool, error)

func PromptUiFunc

func PromptUiFunc[T comparable](label string) func(validator types.Validator[T]) (string, error)

func PromptUiSelectorFunc

func PromptUiSelectorFunc[T comparable](label string, longLabel string, result func(int) error, options types.Future[[]types.Selectable]) func(validator types.Validator[T]) (string, error)

func PromptUiSelectorNewFunc

func PromptUiSelectorNewFunc[T comparable](label string, longLabel string, result func(int) error, options types.Future[[]types.Selectable]) func(validator types.Validator[T]) (string, error)

func RunSubCommand

func RunSubCommand(cmd *cobra.Command, cmds []SelectableCommand)

func SubCommandRequired

func SubCommandRequired(next ...cobra.PositionalArgs) cobra.PositionalArgs

func UseInteractive

func UseInteractive() bool

Types

type Arg

type Arg[T comparable] struct {
	Name       string
	Ptr        *T
	Disabled   types.Future[bool]
	Positional bool
	Validator  types.Validator[T]
	UI         UiFunc[T]
	Callback   func(T) error
}

func (Arg[T]) ToRequiredArg

func (p Arg[T]) ToRequiredArg() rArgInterface

type RequiredArg

type RequiredArg interface {
	ToRequiredArg() rArgInterface
}

type SelectableCommand

type SelectableCommand interface {
	types.Selectable
	Command() *cobra.Command
}

func CmdSelectable

func CmdSelectable(cmd *cobra.Command) SelectableCommand

type UiFunc

type UiFunc[T comparable] func(types.Validator[T]) (T, error)

Jump to

Keyboard shortcuts

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