ui

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ui provides small terminal-interaction primitives the tyche CLI uses to detect TTY state and read single-line interactive input. The package is intentionally minimal — no TUI framework, no colour library, no escape codes — because every command that uses it is short-lived and not a long-running process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal reports whether f is connected to a character device (a TTY). Commands that prompt should refuse to do so when this returns false so a non-interactive invocation in CI or a script does not hang on stdin.

Types

type Prompt

type Prompt struct {
	Out io.Writer
	In  io.Reader
}

Prompt is a tiny single-line input helper. It writes a question to Out and reads one trimmed line from In. The zero value is fine: it uses stdout and stdin.

Prompt is deliberately not a TUI. If you find yourself wanting bubbles or huh here, you have probably outgrown this command and should be writing a script or using a real TUI.

func (Prompt) Ask

func (p Prompt) Ask(question string) (string, error)

Ask writes question to the configured output (stdout by default) and reads a single line of input, trimming trailing whitespace. The leading space in the prompt is intentional: it visually separates the question from the user's input.

func (Prompt) AskDefault

func (p Prompt) AskDefault(question, fallback string) (string, error)

AskDefault is Ask with a fallback value: if the user enters an empty line, it returns default. The default is shown in the prompt so the user knows what they get by pressing enter.

Jump to

Keyboard shortcuts

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