Documentation
¶
Index ¶
- func Size() (width, height int)
- type Recorder
- type RemoteTerm
- type Terminal
- func (t *Terminal) AskYesNo(message string, defaultAnswer bool) bool
- func (t *Terminal) CommandStdout() io.Writer
- func (t *Terminal) FlushAllOutput()
- func (t *Terminal) Print(a ...any) (n int, err error)
- func (t *Terminal) Printf(format string, a ...any) (n int, err error)
- func (t *Terminal) Println(a ...any) (n int, err error)
- func (t *Terminal) ReadPassword() (string, error)
- func (t *Terminal) Scanln(a ...any) (n int, err error)
- func (t *Terminal) Stderr() io.Writer
- func (t *Terminal) StderrIsTerminal() bool
- func (t *Terminal) Stdout() io.Writer
- func (t *Terminal) StdoutIsTerminal() bool
- func (t *Terminal) Write(p []byte) (n int, err error)
- type TerminalOption
- func WithColors(enable bool) TerminalOption
- func WithNoStderr() TerminalOption
- func WithNoStdin() TerminalOption
- func WithNoStdout() TerminalOption
- func WithPrintToStderr() TerminalOption
- func WithStderr(stderr io.Writer) TerminalOption
- func WithStderrCopy(w io.Writer) TerminalOption
- func WithStderrRecorder(recorder *Recorder) TerminalOption
- func WithStdin(stdin io.Reader) TerminalOption
- func WithStdout(stdout io.Writer) TerminalOption
- func WithStdoutCopy(w io.Writer) TerminalOption
- func WithStdoutRecorder(recorder *Recorder) TerminalOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RemoteTerm ¶
type RemoteTerm struct {
// contains filtered or unexported fields
}
RemoteTerm is used to send terminal output remotely
func NewRemoteTerm ¶
func NewRemoteTerm(client *remote.Client) *RemoteTerm
NewRemoteTerm creates a new RemoteTerm based on a remote.Client
type Terminal ¶ added in v0.34.0
type Terminal struct {
// contains filtered or unexported fields
}
Terminal gives access to the standard terminal input/output
func Get ¶ added in v0.34.0
func Get() *Terminal
Get returns the default terminal. It will be initialized on first use with NewTerminal() if not set before. Ideally we should pass the terminal where we need it, but Get() can be safely used until the refactoring is finished.
func NewTerminal ¶ added in v0.34.0
func NewTerminal(options ...TerminalOption) *Terminal
func Set ¶ added in v0.34.0
Set stores the default terminal, and returns the terminal reference for chaining.
func (*Terminal) AskYesNo ¶ added in v0.34.0
AskYesNo prompts the user for a message asking for a yes/no answer
func (*Terminal) CommandStdout ¶ added in v0.35.0
CommandStdout returns the writer to use as the stdout of a child process. Unlike Stdout, it doesn't strip ANSI sequences and ignores WithPrintToStderr.
func (*Terminal) FlushAllOutput ¶ added in v0.34.0
func (t *Terminal) FlushAllOutput()
FlushAllOutput flushes all buffered output (if supported by the underlying Writer).
func (*Terminal) Print ¶ added in v0.34.0
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*Terminal) Printf ¶ added in v0.34.0
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*Terminal) Println ¶ added in v0.34.0
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*Terminal) ReadPassword ¶ added in v0.34.0
ReadPassword reads a password without echoing it to the terminal.
func (*Terminal) StderrIsTerminal ¶ added in v0.34.0
StderrIsTerminal returns true as stderr is a terminal session
func (*Terminal) StdoutIsTerminal ¶ added in v0.34.0
StdoutIsTerminal returns true as stdout is a terminal session
type TerminalOption ¶ added in v0.34.0
type TerminalOption func(t *Terminal)
func WithColors ¶ added in v0.34.0
func WithColors(enable bool) TerminalOption
func WithNoStderr ¶ added in v0.34.0
func WithNoStderr() TerminalOption
func WithNoStdin ¶ added in v0.34.0
func WithNoStdin() TerminalOption
func WithNoStdout ¶ added in v0.34.0
func WithNoStdout() TerminalOption
func WithPrintToStderr ¶ added in v0.35.0
func WithPrintToStderr() TerminalOption
WithPrintToStderr sends the terminal's own output (Print*, Write and Stdout) to stderr. CommandStdout still writes to stdout.
func WithStderr ¶ added in v0.34.0
func WithStderr(stderr io.Writer) TerminalOption
func WithStderrCopy ¶ added in v0.34.0
func WithStderrCopy(w io.Writer) TerminalOption
func WithStderrRecorder ¶ added in v0.34.0
func WithStderrRecorder(recorder *Recorder) TerminalOption
func WithStdin ¶ added in v0.34.0
func WithStdin(stdin io.Reader) TerminalOption
func WithStdout ¶ added in v0.34.0
func WithStdout(stdout io.Writer) TerminalOption
func WithStdoutCopy ¶ added in v0.34.0
func WithStdoutCopy(w io.Writer) TerminalOption
WithStdoutCopy creates a copy of everything sent to Stdout to `copy` writer. Colorisation is independent: the Stdout writer can display colors while the copy to a non terminal won't display colors.
func WithStdoutRecorder ¶ added in v0.34.0
func WithStdoutRecorder(recorder *Recorder) TerminalOption