installerui

package
v0.0.0-...-4f7fa88 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package installerui contains neutral terminal selection and confirmation primitives. Hosts provide product-specific options and interpret the result.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidRequest   = errors.New("invalid terminal request")
	ErrInvalidSelection = errors.New("invalid terminal selection")
)
View Source
var (
	ErrUnavailable = errors.New("installer ui unavailable")
	ErrCancelled   = errors.New("installer ui cancelled") //nolint:misspell // Preserve the public sentinel's existing error text.
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Input  io.Reader
	Output io.Writer
	// ReadLine supplies optional platform-aware cancellation without prefetching.
	ReadLine func(context.Context, io.Reader) (string, error)
	// Style may add trusted formatting to already sanitized labels.
	Style func(string) string
}

type ConfirmRequest

type ConfirmRequest struct {
	Title   string
	Summary []string
	Default bool
}

type Confirmation

type Confirmation struct {
	Accepted  bool
	Cancelled bool //nolint:misspell // Preserve the exported result field for API compatibility.
}

type MultiSelectRequest

type MultiSelectRequest struct {
	SelectRequest
	MinSelected int
}

type Option

type Option struct{ ID, Label string }

type SelectRequest

type SelectRequest struct {
	Title    string
	Options  []Option
	Defaults []string
}

type Selection

type Selection struct {
	IDs       []string
	Accepted  bool
	Cancelled bool //nolint:misspell // Preserve the exported result field for API compatibility.
}

type Terminal

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal owns readers only during a call, never the borrowed descriptors. All calls, including methods on PlainUI, must be sequential on the same TTY. Supply a signal/deadline-aware context to each prompt.

func NewTerminal

func NewTerminal(cfg TerminalConfig) (*Terminal, error)

func (*Terminal) Confirm

func (t *Terminal) Confirm(ctx context.Context, req ConfirmRequest) (result Confirmation, err error)

func (*Terminal) Mode

func (t *Terminal) Mode() TerminalMode

func (*Terminal) PlainUI

func (t *Terminal) PlainUI() (*UI, error)

PlainUI preserves the legacy line API and grammar for action/unit menus. Its cancellable reader joins before return; no reader lives between calls. UI.Confirm has legacy semantics WITHOUT a consent snapshot. Always use Terminal.Confirm for terminal authorization. Rich mode does not affect this UI.

func (*Terminal) SelectMany

func (t *Terminal) SelectMany(ctx context.Context, req MultiSelectRequest) (Selection, error)

type TerminalConfig

type TerminalConfig struct {
	Input   *os.File
	Output  *os.File
	Mode    TerminalMode
	NoColor bool
}

TerminalConfig contains borrowed prompt handles, independent of data stdout. NoColor is the host's effective decision; the UI never reevaluates NO_COLOR.

type TerminalMode

type TerminalMode string

TerminalMode selects interaction without changing host selection or consent policy.

const (
	ModeAuto  TerminalMode = "auto"
	ModeRich  TerminalMode = "rich"
	ModePlain TerminalMode = "plain"
)

type UI

type UI struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*UI, error)

func (*UI) Confirm

func (u *UI) Confirm(ctx context.Context, req ConfirmRequest) (Confirmation, error)

func (*UI) SelectMany

func (u *UI) SelectMany(ctx context.Context, req SelectRequest) (Selection, error)

func (*UI) SelectOne

func (u *UI) SelectOne(ctx context.Context, req SelectRequest) (Selection, error)

Jump to

Keyboard shortcuts

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