mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
termstatus: centralize OutputIsTerminal checks
This commit is contained in:
@@ -19,6 +19,10 @@ type Printer interface {
|
||||
// that are not errors. The message is even printed if --quiet is specified.
|
||||
// Appends a newline if not present.
|
||||
S(msg string, args ...interface{})
|
||||
// PT prints a message if verbosity >= 1 (neither --quiet nor --verbose is specified)
|
||||
// and stdout points to a terminal.
|
||||
// This is used for informational messages.
|
||||
PT(msg string, args ...interface{})
|
||||
// P prints a message if verbosity >= 1 (neither --quiet nor --verbose is specified),
|
||||
// this is used for normal messages which are not errors. Appends a newline if not present.
|
||||
P(msg string, args ...interface{})
|
||||
@@ -47,6 +51,8 @@ func (*NoopPrinter) E(_ string, _ ...interface{}) {}
|
||||
|
||||
func (*NoopPrinter) S(_ string, _ ...interface{}) {}
|
||||
|
||||
func (*NoopPrinter) PT(_ string, _ ...interface{}) {}
|
||||
|
||||
func (*NoopPrinter) P(_ string, _ ...interface{}) {}
|
||||
|
||||
func (*NoopPrinter) V(_ string, _ ...interface{}) {}
|
||||
@@ -82,6 +88,10 @@ func (p *TestPrinter) S(msg string, args ...interface{}) {
|
||||
p.t.Logf("stdout: "+msg, args...)
|
||||
}
|
||||
|
||||
func (p *TestPrinter) PT(msg string, args ...interface{}) {
|
||||
p.t.Logf("stdout(terminal): "+msg, args...)
|
||||
}
|
||||
|
||||
func (p *TestPrinter) P(msg string, args ...interface{}) {
|
||||
p.t.Logf("print: "+msg, args...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user