Documentation
¶
Overview ¶
Package cliui owns inline terminal presentation, not authentication or storage.
Index ¶
- func CanInteract(in io.Reader, out io.Writer) bool
- func ChoiceName(choice string) string
- func PickOrg(ctx context.Context, in io.Reader, out io.Writer, title string, ...) (int, string, error)
- func RunActivity(ctx context.Context, in io.Reader, out io.Writer, initial string, ...) error
- func SafeText(s string) string
- type OrgChoice
- type Printer
- func (p *Printer) Detail(text string)
- func (p *Printer) Fail(format string, a ...any)
- func (p *Printer) Gap()
- func (p *Printer) Input(question string)
- func (p *Printer) Note(format string, a ...any)
- func (p *Printer) Open()
- func (p *Printer) Question(question string, choices ...string)
- func (p *Printer) Section(title string)
- func (p *Printer) Step(format string, a ...any)
- func (p *Printer) Success(format string, a ...any)
- func (p *Printer) Warn(format string, a ...any)
- type TerminalStyles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanInteract ¶
CanInteract requires terminal input and the supplied stderr writer; NO_COLOR does not disable interaction.
func ChoiceName ¶ added in v0.13.0
ChoiceName is a choice's name: what is before a comma or a colon, which says what it does ("no" of "no, skip it"). Typing the name chooses it.
func PickOrg ¶
func PickOrg(ctx context.Context, in io.Reader, out io.Writer, title string, orgs []OrgChoice, cloudURL string, allowURL bool) (int, string, error)
PickOrg returns the original stored index, len(orgs) for hosted, or -1 plus a canonical URL. Esc or Ctrl-C returns context.Canceled. Callers own interaction policy and pass stderr as out.
func RunActivity ¶
func RunActivity(ctx context.Context, in io.Reader, out io.Writer, initial string, work func(context.Context, func(string), func(string)) error) error
RunActivity runs work in a Tea command and waits for its cleanup even after cancellation or a UI error. Progress labels must be bounded and nonsecret. The second callback prints persistent user messages above the activity; callers handle plain mode and final output.
Types ¶
type OrgChoice ¶
OrgChoice is a stored organization's display name and canonical URL, never credentials.
type Printer ¶
type Printer struct {
Styles TerminalStyles
// contains filtered or unexported fields
}
Printer writes a command's progress, warnings, questions and outcomes as lines told apart at a glance: each kind has its mark, colored on a terminal, and a line too long for the terminal wraps under its text, not under its mark. Sections are separated by a blank line. Off a terminal, it writes the same marks without color or wrapping.
func NewPrinter ¶
NewPrinter prints to w, styled and wrapped when w is a terminal.
func (*Printer) Detail ¶
Detail quotes text from elsewhere (a server's message, say), indented under the line before it, its own line breaks kept and its terminal escapes removed.
func (*Printer) Gap ¶
func (p *Printer) Gap()
Gap separates what comes next from what came before with a blank line.
func (*Printer) Input ¶ added in v0.13.0
Input writes a question that takes a line of text, leaving the cursor after it for the answer.
func (*Printer) Open ¶
func (p *Printer) Open()
Open writes a pending section's heading now, before something else writes to the same place: a question asked through another Printer, say.
func (*Printer) Question ¶
Question writes a question with its choices, the last the default, leaving the cursor after it for the answer. A choice can say what it does after its name, following a comma or a colon ("no, skip it"); the question then lists its choices one to a line, and names the default by its name alone.
func (*Printer) Section ¶
Section starts a group of lines under a heading, written with its first line: a section with nothing in it shows nothing.
type TerminalStyles ¶
type TerminalStyles struct {
Heading, Muted, Accent, Selection, Success, Warning, Error, Link, Code lipgloss.Style
}
TerminalStyles gives auth views a shared hierarchy; its zero value renders plain text.
func NewTerminalStyles ¶
func NewTerminalStyles(out io.Writer) TerminalStyles
NewTerminalStyles styles only terminal output, respecting NO_COLOR, CI and TERM=dumb. ANSI colors use the user's terminal palette rather than assuming a light or dark background.