From 57dd6e6482227ad81e870898864b60721b1feb4e Mon Sep 17 00:00:00 2001 From: Dark Dragon Date: Wed, 5 Feb 2025 22:59:26 +0100 Subject: [PATCH] prune: Add JSON output --- cmd/restic/cmd_prune.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 59ea782ef..4fda7c68b 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -211,9 +211,13 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption printer.P("\nWould have made the following changes:") } - err = printPruneStats(printer, plan.Stats()) - if err != nil { - return err + if !gopts.JSON { + err = printPruneStats(printer, plan.Stats()) + if err != nil { + return err + } + } else { + term.Print(ui.ToJSONString(plan.Stats())) } // Trigger GC to reset garbage collection threshold