mirror of
https://github.com/restic/restic.git
synced 2026-11-05 06:49:21 +00:00
restic: move Printer interface from internal/ui/progress
Move Printer and NewNoopPrinter to internal/restic so repository does not have to import the ui packages.
This commit is contained in:
1 parent
0f4236cb39
commit
d9d54a505e
44 files changed
+165
-173
No files matched your search
@@ -3,12 +3,13 @@ package restore
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/ui"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
type jsonPrinter struct {
|
||||
progress.Printer
|
||||
restic.Printer
|
||||
|
||||
terminal ui.Terminal
|
||||
verbosity uint
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
@@ -38,7 +39,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
|
||||
restic.Printer
|
||||
}
|
||||
|
||||
type ItemAction string
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package restore
|
||||
|
||||
import (
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -37,7 +38,7 @@ type mockPrinter struct {
|
||||
trace printerTrace
|
||||
items itemTrace
|
||||
errors errorTrace
|
||||
progress.Printer
|
||||
restic.Printer
|
||||
}
|
||||
|
||||
const mockFinishDuration = 42 * time.Second
|
||||
@@ -57,7 +58,7 @@ func (p *mockPrinter) Finish(progress State, _ time.Duration) {
|
||||
}
|
||||
|
||||
func testProgress(fn func(progress *Progress) bool) (printerTrace, itemTrace, errorTrace) {
|
||||
printer := &mockPrinter{Printer: progress.NewNoopPrinter()}
|
||||
printer := &mockPrinter{Printer: restic.NewNoopPrinter()}
|
||||
progress := newProgress(printer, 0)
|
||||
final := fn(progress)
|
||||
progress.update(0, final)
|
||||
|
||||
@@ -4,12 +4,13 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/restic"
|
||||
"github.com/restic/restic/internal/ui"
|
||||
"github.com/restic/restic/internal/ui/progress"
|
||||
)
|
||||
|
||||
type textPrinter struct {
|
||||
progress.Printer
|
||||
restic.Printer
|
||||
|
||||
terminal ui.Terminal
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user