diff --git a/cmd/restic/cmd_check.go b/cmd/restic/cmd_check.go index f87303933..f1c0516c2 100644 --- a/cmd/restic/cmd_check.go +++ b/cmd/restic/cmd_check.go @@ -262,10 +262,10 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args for _, hint := range hints { switch hint.(type) { case *checker.ErrDuplicatePacks: - term.Print(hint.Error()) + printer.S("%s", hint.Error()) summary.HintRepairIndex = true case *checker.ErrMixedPack: - term.Print(hint.Error()) + printer.S("%s", hint.Error()) summary.HintPrune = true default: printer.E("error: %v\n", hint) @@ -274,10 +274,10 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args } if summary.HintRepairIndex { - term.Print("Duplicate packs are non-critical, you can run `restic repair index' to correct this.\n") + printer.S("Duplicate packs are non-critical, you can run `restic repair index' to correct this.\n") } if summary.HintPrune { - term.Print("Mixed packs with tree and data blobs are non-critical, you can run `restic prune` to correct this.\n") + printer.S("Mixed packs with tree and data blobs are non-critical, you can run `restic prune` to correct this.\n") } if len(errs) > 0 { @@ -534,6 +534,7 @@ func (p *jsonErrorPrinter) E(msg string, args ...interface{}) { } p.term.Error(ui.ToJSONString(status)) } +func (*jsonErrorPrinter) S(_ string, _ ...interface{}) {} func (*jsonErrorPrinter) P(_ string, _ ...interface{}) {} func (*jsonErrorPrinter) V(_ string, _ ...interface{}) {} func (*jsonErrorPrinter) VV(_ string, _ ...interface{}) {} diff --git a/internal/ui/message.go b/internal/ui/message.go index 6ad5a439e..6ba60f3c0 100644 --- a/internal/ui/message.go +++ b/internal/ui/message.go @@ -24,6 +24,12 @@ func (m *Message) E(msg string, args ...interface{}) { m.term.Error(fmt.Sprintf(msg, args...)) } +// S prints a message, this is should only be used for very important messages +// that are not errors. +func (m *Message) S(msg string, args ...interface{}) { + m.term.Print(fmt.Sprintf(msg, args...)) +} + // P prints a message if verbosity >= 1, this is used for normal messages which // are not errors. func (m *Message) P(msg string, args ...interface{}) { diff --git a/internal/ui/progress/printer.go b/internal/ui/progress/printer.go index a2bc4c4b5..c3e0d17a3 100644 --- a/internal/ui/progress/printer.go +++ b/internal/ui/progress/printer.go @@ -8,9 +8,15 @@ import "testing" type Printer interface { NewCounter(description string) *Counter + // E prints to stderr E(msg string, args ...interface{}) + // S prints to stdout + S(msg string, args ...interface{}) + // P prints to stdout unless quiet was passed P(msg string, args ...interface{}) + // V prints to stdout if verbose is set once V(msg string, args ...interface{}) + // VV prints to stdout if verbose is set twice VV(msg string, args ...interface{}) } @@ -25,6 +31,8 @@ func (*NoopPrinter) NewCounter(_ string) *Counter { func (*NoopPrinter) E(_ string, _ ...interface{}) {} +func (*NoopPrinter) S(_ string, _ ...interface{}) {} + func (*NoopPrinter) P(_ string, _ ...interface{}) {} func (*NoopPrinter) V(_ string, _ ...interface{}) {} @@ -52,6 +60,10 @@ func (p *TestPrinter) E(msg string, args ...interface{}) { p.t.Logf("error: "+msg, args...) } +func (p *TestPrinter) S(msg string, args ...interface{}) { + p.t.Logf("stdout: "+msg, args...) +} + func (p *TestPrinter) P(msg string, args ...interface{}) { p.t.Logf("print: "+msg, args...) }