mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
consider JSON flag in newTerminalProgressPrinter
This commit is contained in:
@@ -228,7 +228,7 @@ func runCheck(ctx context.Context, opts CheckOptions, gopts GlobalOptions, args
|
||||
|
||||
var printer progress.Printer
|
||||
if !gopts.JSON {
|
||||
printer = newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer = newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
} else {
|
||||
printer = newJSONErrorPrinter(term)
|
||||
}
|
||||
|
||||
@@ -194,11 +194,7 @@ func runForget(ctx context.Context, opts ForgetOptions, pruneOptions PruneOption
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
verbosity := gopts.verbosity
|
||||
if gopts.JSON {
|
||||
verbosity = 0
|
||||
}
|
||||
printer := newTerminalProgressPrinter(verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
var snapshots restic.Snapshots
|
||||
removeSnIDs := restic.NewIDSet()
|
||||
|
||||
@@ -136,7 +136,7 @@ func applyMigrations(ctx context.Context, opts MigrateOptions, gopts GlobalOptio
|
||||
}
|
||||
|
||||
func runMigrate(ctx context.Context, opts MigrateOptions, gopts GlobalOptions, args []string, term *termstatus.Terminal) error {
|
||||
printer := newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
ctx, repo, unlock, err := openWithExclusiveLock(ctx, gopts, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -191,7 +191,7 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption
|
||||
Print("warning: running prune without a cache, this may be very slow!\n")
|
||||
}
|
||||
|
||||
printer := newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
printer.P("loading indexes...\n")
|
||||
// loading the index before the snapshots is ok, as we use an exclusive lock here
|
||||
|
||||
@@ -55,7 +55,7 @@ func runRecover(ctx context.Context, gopts GlobalOptions, term *termstatus.Termi
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
printer := newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
snapshotLister, err := restic.MemorizeList(ctx, repo, restic.SnapshotFile)
|
||||
if err != nil {
|
||||
|
||||
@@ -79,7 +79,7 @@ func runRebuildIndex(ctx context.Context, opts RepairIndexOptions, gopts GlobalO
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
printer := newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
err = repository.RepairIndex(ctx, repo, repository.RepairIndexOptions{
|
||||
ReadAllPacks: opts.ReadAllPacks,
|
||||
|
||||
@@ -59,7 +59,7 @@ func runRepairPacks(ctx context.Context, gopts GlobalOptions, term *termstatus.T
|
||||
}
|
||||
defer unlock()
|
||||
|
||||
printer := newTerminalProgressPrinter(gopts.verbosity, term)
|
||||
printer := newTerminalProgressPrinter(gopts.JSON, gopts.verbosity, term)
|
||||
|
||||
bar := newIndexTerminalProgress(gopts.Quiet, gopts.JSON, term)
|
||||
err = repo.LoadIndex(ctx, bar)
|
||||
|
||||
@@ -120,7 +120,10 @@ func (t *terminalProgressPrinter) NewCounter(description string) *progress.Count
|
||||
return newTerminalProgressMax(t.show, 0, description, t.term)
|
||||
}
|
||||
|
||||
func newTerminalProgressPrinter(verbosity uint, term *termstatus.Terminal) progress.Printer {
|
||||
func newTerminalProgressPrinter(json bool, verbosity uint, term *termstatus.Terminal) progress.Printer {
|
||||
if json {
|
||||
verbosity = 0
|
||||
}
|
||||
return &terminalProgressPrinter{
|
||||
term: term,
|
||||
Message: *ui.NewMessage(term, verbosity),
|
||||
|
||||
Reference in New Issue
Block a user