prune: Add JSON output

This commit is contained in:
Dark Dragon 2025-02-05 22:59:26 +01:00
parent ae0835f12d
commit 57dd6e6482
1 changed files with 7 additions and 3 deletions

View File

@ -211,9 +211,13 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption
printer.P("\nWould have made the following changes:") printer.P("\nWould have made the following changes:")
} }
err = printPruneStats(printer, plan.Stats()) if !gopts.JSON {
if err != nil { err = printPruneStats(printer, plan.Stats())
return err if err != nil {
return err
}
} else {
term.Print(ui.ToJSONString(plan.Stats()))
} }
// Trigger GC to reset garbage collection threshold // Trigger GC to reset garbage collection threshold