ui

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Trace = ui.Trace
	Debug = ui.Debug
	Info  = ui.Info
	Warn  = ui.Warn
	Error = ui.Error
	None  = ui.None
)
View Source
var (
	Magenta = ui.Magenta
	Cyan    = ui.Green
	Green   = ui.Green
	Yellow  = ui.Yellow
	Red     = ui.Red
)

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Key   string
	Value string
}

type Item

type Item struct {
	Key         string
	Name        string
	Description string
	Attributes  []Attribute
}

Item represents an item for selection.

type SearchFunc

type SearchFunc func(string, int) bool

SearchFunc is a function for searching and matching items in select.

type UI

type UI interface {
	ui.UI
	Confrim(prompt string, Default bool) (bool, error)
	Ask(prompt, Default string, f ValidateFunc) (string, error)
	AskSecret(prompt string, confirm bool, f ValidateFunc) (string, error)
	Select(prompt string, size int, items []Item, f SearchFunc) (Item, error)
}

UI is the interface for interacting with users in command-line applications.

func NewInteractive

func NewInteractive(level ui.Level) UI

NewInteractive creates a new interactive user interface. This is a concurrent-safe UI and can be used across multiple Go routines.

func NewNop

func NewNop() UI

NewNop creates a nop user interface for testing purposes.

type ValidateFunc

type ValidateFunc func(string) error

ValidateFunc is a function for validating user inputs.

Jump to

Keyboard shortcuts

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