2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 02:48:55 +00:00

debug: get stdout/stderr from gopts/globalOptions

This commit is contained in:
Michael Eischer 2020-04-04 00:00:21 +02:00
parent 08bf3bae79
commit 7aa2f8a61e

View File

@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"os"
"github.com/spf13/cobra"
@ -90,7 +89,7 @@ func printPacks(repo *repository.Repository, wr io.Writer) error {
blobs, err := pack.List(repo.Key(), restic.ReaderAt(repo.Backend(), h), size)
if err != nil {
fmt.Fprintf(os.Stderr, "error for pack %v: %v\n", id.Str(), err)
fmt.Fprintf(globalOptions.stderr, "error for pack %v: %v\n", id.Str(), err)
return nil
}
@ -151,20 +150,20 @@ func runDebugDump(gopts GlobalOptions, args []string) error {
switch tpe {
case "indexes":
return dumpIndexes(repo, os.Stdout)
return dumpIndexes(repo, gopts.stdout)
case "snapshots":
return debugPrintSnapshots(repo, os.Stdout)
return debugPrintSnapshots(repo, gopts.stdout)
case "packs":
return printPacks(repo, os.Stdout)
return printPacks(repo, gopts.stdout)
case "all":
fmt.Printf("snapshots:\n")
err := debugPrintSnapshots(repo, os.Stdout)
err := debugPrintSnapshots(repo, gopts.stdout)
if err != nil {
return err
}
fmt.Printf("\nindexes:\n")
err = dumpIndexes(repo, os.Stdout)
err = dumpIndexes(repo, gopts.stdout)
if err != nil {
return err
}