mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
restore: print JSON versions of errors in --json mode
Previously, they were printed as freeform text. This also adds a ui.Terminal interface to make writing tests easier and also adds a few tests.
This commit is contained in:
@@ -32,13 +32,9 @@ type progressInfoEntry struct {
|
||||
bytesTotal uint64
|
||||
}
|
||||
|
||||
type term interface {
|
||||
Print(line string)
|
||||
SetStatus(lines []string)
|
||||
}
|
||||
|
||||
type ProgressPrinter interface {
|
||||
Update(progress State, duration time.Duration)
|
||||
Error(item string, err error) error
|
||||
CompleteItem(action ItemAction, item string, size uint64)
|
||||
Finish(progress State, duration time.Duration)
|
||||
}
|
||||
@@ -139,6 +135,17 @@ func (p *Progress) ReportDeletedFile(name string) {
|
||||
p.printer.CompleteItem(ActionDeleted, name, 0)
|
||||
}
|
||||
|
||||
func (p *Progress) Error(item string, err error) error {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
return p.printer.Error(item, err)
|
||||
}
|
||||
|
||||
func (p *Progress) Finish() {
|
||||
p.updater.Done()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user