mirror of
https://github.com/restic/restic.git
synced 2024-12-23 08:16:36 +00:00
Merge pull request #1754 from restic/fix-quiet
backup: Disable status output for --quiet
This commit is contained in:
commit
2a67258867
3 changed files with 9 additions and 4 deletions
|
@ -48,7 +48,7 @@ given as the arguments.
|
||||||
}
|
}
|
||||||
|
|
||||||
var t tomb.Tomb
|
var t tomb.Tomb
|
||||||
term := termstatus.New(globalOptions.stdout, globalOptions.stderr)
|
term := termstatus.New(globalOptions.stdout, globalOptions.stderr, globalOptions.Quiet)
|
||||||
t.Go(func() error { term.Run(t.Context(globalOptions.ctx)); return nil })
|
t.Go(func() error { term.Run(t.Context(globalOptions.ctx)); return nil })
|
||||||
|
|
||||||
err := runBackup(backupOptions, globalOptions, term, args)
|
err := runBackup(backupOptions, globalOptions, term, args)
|
||||||
|
|
|
@ -59,7 +59,7 @@ func testRunBackup(t testing.TB, dir string, target []string, opts BackupOptions
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
var wg errgroup.Group
|
var wg errgroup.Group
|
||||||
term := termstatus.New(gopts.stdout, gopts.stderr)
|
term := termstatus.New(gopts.stdout, gopts.stderr, gopts.Quiet)
|
||||||
wg.Go(func() error { term.Run(ctx); return nil })
|
wg.Go(func() error { term.Run(ctx); return nil })
|
||||||
|
|
||||||
gopts.stdout = ioutil.Discard
|
gopts.stdout = ioutil.Discard
|
||||||
|
|
|
@ -44,8 +44,9 @@ type fder interface {
|
||||||
// a file (e.g. via shell output redirection) or is just an io.Writer (not the
|
// a file (e.g. via shell output redirection) or is just an io.Writer (not the
|
||||||
// open *os.File for stdout), no status lines are printed. The status lines and
|
// open *os.File for stdout), no status lines are printed. The status lines and
|
||||||
// normal output (via Print/Printf) are written to wr, error messages are
|
// normal output (via Print/Printf) are written to wr, error messages are
|
||||||
// written to errWriter.
|
// written to errWriter. If disableStatus is set to true, no status messages
|
||||||
func New(wr io.Writer, errWriter io.Writer) *Terminal {
|
// are printed even if the terminal supports it.
|
||||||
|
func New(wr io.Writer, errWriter io.Writer, disableStatus bool) *Terminal {
|
||||||
t := &Terminal{
|
t := &Terminal{
|
||||||
wr: bufio.NewWriter(wr),
|
wr: bufio.NewWriter(wr),
|
||||||
errWriter: errWriter,
|
errWriter: errWriter,
|
||||||
|
@ -54,6 +55,10 @@ func New(wr io.Writer, errWriter io.Writer) *Terminal {
|
||||||
status: make(chan status),
|
status: make(chan status),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if disableStatus {
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
if d, ok := wr.(fder); ok && canUpdateStatus(d.Fd()) {
|
if d, ok := wr.(fder); ok && canUpdateStatus(d.Fd()) {
|
||||||
// only use the fancy status code when we're running on a real terminal.
|
// only use the fancy status code when we're running on a real terminal.
|
||||||
t.canUpdateStatus = true
|
t.canUpdateStatus = true
|
||||||
|
|
Loading…
Reference in a new issue