ui

package
v0.51.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileReader added in v0.44.0

type FileReader interface {
	io.Reader
	Fd() uintptr
}

FileReader represents the input of a terminal

type FileWriter added in v0.44.0

type FileWriter interface {
	io.Writer
	Fd() uintptr
}

FileWriter represents the output of a terminal

type InputOption

type InputOption func(*survey.Input)

InputOption represets a funcion the customizes a survey.Input object

func WithDefault

func WithDefault(d string) InputOption

WithDefault will set a default answer to the question

func WithHelp

func WithHelp(help string) InputOption

WithHelp add help to input question

func WithSuggestion

func WithSuggestion(fn func(toComplete string) []string) InputOption

WithSuggestion applies the suggestion function to the input question

type RGB

type RGB [3]int

func HEX

func HEX(hex string) (RGB, error)

func (RGB) B

func (c RGB) B() int

func (RGB) G

func (c RGB) G() int

func (RGB) R

func (c RGB) R() int

func (RGB) Values

func (c RGB) Values() []int

type UI added in v0.44.0

type UI interface {
	// SetPageSize changes how many entries are shown on AskFromOptions and
	// AskManyFromOptions at a time
	SetPageSize(p uint) UI
	// AskForText interactively ask for one string from the user
	AskForText(m string, opts ...InputOption) (string, error)
	// AskForValidText for a string interactively from the user and validates
	// it
	AskForValidText(
		m string, validate func(string) error, opts ...InputOption,
	) (string, error)
	// AskForDateTime interactively ask for one date and time from the user
	AskForDateTime(m, d string, ct convertTime) (time.Time, error)
	// AskForDateTimeOrNil interactively ask for one date and time from the
	// user, but allows a empty response
	AskForDateTimeOrNil(m, d string, ct convertTime) (*time.Time, error)
	// AskForInt interactively ask for one int from the user
	AskForInt(m string, d int) (int, error)
	// AskFromOptions interactively ask the user to choose one option or none
	AskFromOptions(m string, o []string, d string) (string, error)
	// AskManyFromOptions interactively ask the user to choose none or many
	// option
	AskManyFromOptions(
		m string, o, d []string, validade func([]string) error,
	) ([]string, error)
	// Confirm interactively ask the user a yes/no question
	Confirm(m string, d bool) (bool, error)
}

UI provides functions to prompt information from a terminal

func NewUI added in v0.44.0

func NewUI(in FileReader, out FileWriter, err io.Writer) UI

NewUI creates a new UI instance

Jump to

Keyboard shortcuts

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