restic/internal/ui/terminal.go

37 lines
1.3 KiB
Go
Raw Permalink Normal View History

package ui
import (
"context"
"io"
)
// Terminal is used to write messages and display status lines which can be
// updated. See termstatus.Terminal for a concrete implementation.
type Terminal interface {
// Print writes a line to the terminal. Appends a newline if not present.
Print(line string)
// Error writes an error to the terminal. Appends a newline if not present.
Error(line string)
// SetStatus sets the status lines to the terminal.
SetStatus(lines []string)
// CanUpdateStatus returns true if the terminal can update the status lines.
CanUpdateStatus() bool
2025-09-21 17:17:24 +02:00
// InputRaw returns the input reader.
InputRaw() io.ReadCloser
2025-09-21 17:17:24 +02:00
// InputIsTerminal returns true if the input is a terminal.
InputIsTerminal() bool
2025-09-21 17:17:24 +02:00
// ReadPassword reads the password from the terminal.
ReadPassword(ctx context.Context, prompt string) (string, error)
2025-09-21 17:17:24 +02:00
// OutputWriter returns a output writer that is safe for concurrent use with
// other output methods. Output is only shown after a line break.
OutputWriter() io.Writer
2025-09-21 17:17:24 +02:00
// OutputRaw returns the raw output writer. Should only be used if there is no
// other option. Must not be used in combination with Print, Error, SetStatus
// or any other method that writes to the terminal.
OutputRaw() io.Writer
2025-09-21 17:17:24 +02:00
// OutputIsTerminal returns true if the output is a terminal.
OutputIsTerminal() bool
}