terminal

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level int

Level is the output level.

type Opt

type Opt func(*UI)

Opt is a UI option.

func WithAskPrefix

func WithAskPrefix(p string) Opt

WithAskPrefix sets the ask prefix.

func WithAskSecretPrefix

func WithAskSecretPrefix(p string) Opt

WithAskSecretPrefix sets the ask prefix.

func WithColor

func WithColor(use bool) Opt

WithColor sets whether or not to use color.

func WithErrorPrefix

func WithErrorPrefix(p string) Opt

WithErrorPrefix sets the error prefix.

func WithInfoPrefix

func WithInfoPrefix(p string) Opt

WithInfoPrefix sets the info prefix.

func WithLevel

func WithLevel(l pb.UI_Settings_Level) Opt

WithLevel sets logging level.

func WithOutputPrefix

func WithOutputPrefix(p string) Opt

WithOutputPrefix sets the output prefix.

func WithStderr

func WithStderr(stderr io.Writer) Opt

WithStderr sets stderr.

func WithStdin

func WithStdin(stdin io.Reader) Opt

WithStdin sets stdin.

func WithStdout

func WithStdout(stdout io.Writer) Opt

WithStdout sets stdout.

func WithWarnPrefix

func WithWarnPrefix(p string) Opt

WithWarnPrefix sets the warn prefix.

func WithWidth

func WithWidth(wrap uint) Opt

WithWidth sets the line wrapping.

type UI

type UI struct {
	Stderr io.Writer
	Stdout io.Writer
	Stdin  io.Reader

	UseColor bool
	Width    uint

	AskPrefix       string
	AskSecretPrefix string
	OutputPrefix    string
	InfoPrefix      string
	ErrorPrefix     string
	WarnPrefix      string

	Level pb.UI_Settings_Level
	// contains filtered or unexported fields
}

UI is a CLI UI.

func NewUI

func NewUI(opts ...Opt) *UI

NewUI takes zero or more options and returns a new UI.

func (*UI) Ask

func (u *UI) Ask(q string) (string, error)

Ask prompts the user for some data.

func (*UI) AskSecret

func (u *UI) AskSecret(q string) (string, error)

AskSecret prompts the user for some data.

func (*UI) Debug

func (u *UI) Debug(m string)

Debug outputs a message at warn level.

func (*UI) Diagnostics

func (u *UI) Diagnostics(files map[string]*hcl.File, diags hcl.Diagnostics) error

Diagnostics outputs diagnostics to stderr.

func (*UI) Error

func (u *UI) Error(m string)

Error outputs a message at error level.

func (*UI) Info

func (u *UI) Info(m string)

Info outputs a message at info level.

func (*UI) Output

func (u *UI) Output(m string)

Output outputs a message to stdout.

func (*UI) RenderTable

func (u *UI) RenderTable(header []string, rows [][]string)

RenderTable does a basic render of table data to the desired writer.

func (*UI) Warn

func (u *UI) Warn(m string)

Warn outputs a message at warn level.

Jump to

Keyboard shortcuts

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