mirror of
https://github.com/restic/restic.git
synced 2025-12-12 07:41:50 +00:00
termstatus: allow retrieving the underlying writer
This is intended for special cases where it must be guaranteed that the output on stdout exactly matches what was written to the io.Writer.
This commit is contained in:
@@ -12,8 +12,11 @@ import (
|
||||
"golang.org/x/text/width"
|
||||
|
||||
"github.com/restic/restic/internal/terminal"
|
||||
"github.com/restic/restic/internal/ui"
|
||||
)
|
||||
|
||||
var _ ui.Terminal = &Terminal{}
|
||||
|
||||
// Terminal is used to write messages and display status lines which can be
|
||||
// updated. When the output is redirected to a file, the status lines are not
|
||||
// printed.
|
||||
@@ -83,6 +86,13 @@ func (t *Terminal) CanUpdateStatus() bool {
|
||||
return t.canUpdateStatus
|
||||
}
|
||||
|
||||
// OutputRaw returns the 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 {
|
||||
return t.wr
|
||||
}
|
||||
|
||||
// Run updates the screen. It should be run in a separate goroutine. When
|
||||
// ctx is cancelled, the status lines are cleanly removed.
|
||||
func (t *Terminal) Run(ctx context.Context) {
|
||||
|
||||
Reference in New Issue
Block a user