Help us shape the future of Go! Take the 2026 Go Developer Survey

ui

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Green  = color.New(color.FgGreen).SprintFunc()
	Red    = color.New(color.FgRed).SprintFunc()
	Yellow = color.New(color.FgYellow).SprintFunc()
	Cyan   = color.New(color.FgCyan).SprintFunc()
	Bold   = color.New(color.Bold).SprintFunc()
	Faint  = color.New(color.Faint).SprintFunc()
)

Functions

func Choose added in v0.8.0

func Choose(question string, options []string) int

Choose presents a numbered menu and returns the 0-based index of the chosen option. Off a terminal, or on blank/invalid input, it returns 0 (the first option).

func Confirm added in v0.8.0

func Confirm(question string, def bool) bool

Confirm asks a yes/no question. Off a terminal, or on blank input, it returns def.

func EditString added in v0.8.0

func EditString(question, current string) string

EditString prompts for a replacement value, showing the current one. Off a terminal, or on blank input (just Enter), it keeps current.

func IsInteractive added in v0.8.0

func IsInteractive() bool

IsInteractive reports whether stdin is a terminal, so callers can choose an interactive flow versus a non-blocking default.

func ReadPassphrase added in v0.6.0

func ReadPassphrase(prompt string, confirm bool) (string, error)

ReadPassphrase reads a passphrase from the controlling terminal without echo. When confirm is true it prompts a second time and verifies the two inputs match (used when setting a new passphrase).

func ReadPassphraseOptional added in v0.6.0

func ReadPassphraseOptional(prompt string) (string, error)

ReadPassphraseOptional reads a passphrase without echo. Empty input is returned as "" without error (caller treats as "skip"). Use for optional backup-passphrase prompts.

Types

type PromptFunc added in v0.8.0

type PromptFunc func(prompt string) (line string, isTTY bool)

PromptFunc writes a prompt to stderr and reads one line of input. isTTY is false when stdin is not a terminal, so callers fall back to a default instead of blocking — important for the session-start hook and CI. Injectable so the interactive helpers can be tested without a real terminal, mirroring the crypto.DefaultPassphraseFunc seam.

var DefaultPrompt PromptFunc = readLine

DefaultPrompt is the production line reader.

Jump to

Keyboard shortcuts

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