mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
restore: embed progress.Printer in restore-specific printer
This commit is contained in:
@@ -999,6 +999,7 @@ func TestRestorerSparseOverwrite(t *testing.T) {
|
||||
|
||||
type printerMock struct {
|
||||
s restoreui.State
|
||||
progress.NoopPrinter
|
||||
}
|
||||
|
||||
func (p *printerMock) Update(_ restoreui.State, _ time.Duration) {
|
||||
|
||||
@@ -4,15 +4,19 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/ui"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
type jsonPrinter struct {
|
||||
progress.Printer
|
||||
|
||||
terminal ui.Terminal
|
||||
verbosity uint
|
||||
}
|
||||
|
||||
func NewJSONProgress(terminal ui.Terminal, verbosity uint) ProgressPrinter {
|
||||
return &jsonPrinter{
|
||||
Printer: ui.NewProgressPrinter(true, verbosity, terminal),
|
||||
terminal: terminal,
|
||||
verbosity: verbosity,
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ type ProgressPrinter interface {
|
||||
Error(item string, err error) error
|
||||
CompleteItem(action ItemAction, item string, size uint64)
|
||||
Finish(progress State, duration time.Duration)
|
||||
progress.Printer
|
||||
}
|
||||
|
||||
type ItemAction string
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/restic/restic/internal/errors"
|
||||
"github.com/restic/restic/internal/test"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
type printerTraceEntry struct {
|
||||
@@ -36,6 +37,7 @@ type mockPrinter struct {
|
||||
trace printerTrace
|
||||
items itemTrace
|
||||
errors errorTrace
|
||||
progress.NoopPrinter
|
||||
}
|
||||
|
||||
const mockFinishDuration = 42 * time.Second
|
||||
|
||||
@@ -5,17 +5,18 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/ui"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
type textPrinter struct {
|
||||
*ui.Message
|
||||
progress.Printer
|
||||
|
||||
terminal ui.Terminal
|
||||
}
|
||||
|
||||
func NewTextProgress(terminal ui.Terminal, verbosity uint) ProgressPrinter {
|
||||
return &textPrinter{
|
||||
Message: ui.NewMessage(terminal, verbosity),
|
||||
Printer: ui.NewProgressPrinter(false, verbosity, terminal),
|
||||
terminal: terminal,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user