cliui

package
v28.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(s *Session)

Option configures session options.

func IgnoreEvents

func IgnoreEvents() Option

IgnoreEvents configures the session to avoid displaying events. This is a compatibility option to be able to use the session and the events bus when models are used to manage CLI UI. The session won't handle the events when this option is present.

func StartSpinner

func StartSpinner() Option

StartSpinner forces spinner to be spinning right after creation.

func StartSpinnerWithText

func StartSpinnerWithText(text string) Option

StartSpinnerWithText forces spinner to be spinning right after creation with a custom status text.

func WithStderr

func WithStderr(stderr io.WriteCloser) Option

WithStderr sets base stderr for a Session.

func WithStdin

func WithStdin(stdin io.ReadCloser) Option

WithStdin sets the starndard input for the session.

func WithStdout

func WithStdout(stdout io.WriteCloser) Option

WithStdout sets the starndard output for the session.

func WithVerbosity

func WithVerbosity(v uilog.Verbosity) Option

WithVerbosity sets a verbosity level for the Session.

type Session

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

Session controls command line interaction with users.

func New

func New(options ...Option) *Session

New creates a new Session.

func (Session) Ask

func (s Session) Ask(questions ...cliquiz.Question) error

Ask asks questions in the terminal and collect answers.

func (Session) AskConfirm

func (s Session) AskConfirm(message string) error

AskConfirm asks yes/no question in the terminal.

func (*Session) End

func (s *Session) End()

End finishes the session by stopping the spinner and the event bus. Once the session is ended it should not be used anymore.

func (Session) EventBus

func (s Session) EventBus() events.Bus

EventBus returns the event bus of the session.

func (Session) NewOutput

func (s Session) NewOutput(label, color string) uilog.Output

NewOutput returns a new logging output bound to the session. The new output will use the session's verbosity, stderr and stdout. Label and color arguments are used to prefix the output when the session verbosity is verbose.

func (Session) PauseSpinner

func (s Session) PauseSpinner() (restart func())

PauseSpinner pauses spinner and returns a function to restart the spinner.

func (Session) Print

func (s Session) Print(messages ...interface{}) error

Print prints arbitrary message.

func (Session) PrintTable

func (s Session) PrintTable(header []string, entries ...[]string) error

PrintTable prints table data.

func (Session) Printf

func (s Session) Printf(format string, a ...interface{}) error

Printf prints formatted arbitrary message.

func (Session) Println

func (s Session) Println(messages ...interface{}) error

Println prints arbitrary message with line break.

func (*Session) StartSpinner

func (s *Session) StartSpinner(text string)

StartSpinner starts the spinner.

func (Session) StopSpinner

func (s Session) StopSpinner()

StopSpinner stops the spinner.

func (Session) Verbosity

func (s Session) Verbosity() uilog.Verbosity

Verbosity returns the verbosity level for the session output.

Directories

Path Synopsis
Package cliquiz is a tool to collect answers from the users on cli.
Package cliquiz is a tool to collect answers from the users on cli.
Package lineprefixer is a helpers to add prefixes to new lines.
Package lineprefixer is a helpers to add prefixes to new lines.
Package prefixgen is a prefix generation helper for log messages and any other kind.
Package prefixgen is a prefix generation helper for log messages and any other kind.
view

Jump to

Keyboard shortcuts

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