From b459d662884a7f3d88a2d289b2b095f50e7fa559 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 21 Sep 2025 17:17:24 +0200 Subject: [PATCH] termstatus: additional comments --- internal/ui/terminal.go | 8 +++++++- internal/ui/termstatus/status.go | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/ui/terminal.go b/internal/ui/terminal.go index e3052c5e1..d4d5a10de 100644 --- a/internal/ui/terminal.go +++ b/internal/ui/terminal.go @@ -17,14 +17,20 @@ type Terminal interface { // CanUpdateStatus returns true if the terminal can update the status lines. CanUpdateStatus() bool + // InputRaw returns the input reader. InputRaw() io.ReadCloser + // InputIsTerminal returns true if the input is a terminal. InputIsTerminal() bool + // ReadPassword reads the password from the terminal. ReadPassword(ctx context.Context, prompt string) (string, error) + // 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 - // OutputRaw returns the output writer. Should only be used if there is no + // 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 + // OutputIsTerminal returns true if the output is a terminal. OutputIsTerminal() bool } diff --git a/internal/ui/termstatus/status.go b/internal/ui/termstatus/status.go index 3d9b2d857..17f51c261 100644 --- a/internal/ui/termstatus/status.go +++ b/internal/ui/termstatus/status.go @@ -164,6 +164,8 @@ func (t *Terminal) CanUpdateStatus() bool { return t.canUpdateStatus } +// OutputWriter returns a output writer that is safe for concurrent use with +// other output methods. Output is only shown after a line break. func (t *Terminal) OutputWriter() io.Writer { t.outputWriterOnce.Do(func() { t.outputWriter = newLineWriter(t.Print) @@ -171,7 +173,7 @@ func (t *Terminal) OutputWriter() io.Writer { return t.outputWriter } -// OutputRaw returns the output writer. Should only be used if there is no +// 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. func (t *Terminal) OutputRaw() io.Writer {