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,10 +211,14 @@ 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:")
} }
if !gopts.JSON {
err = printPruneStats(printer, plan.Stats()) err = printPruneStats(printer, plan.Stats())
if err != nil { if err != nil {
return err return err
} }
} else {
term.Print(ui.ToJSONString(plan.Stats()))
}
// Trigger GC to reset garbage collection threshold // Trigger GC to reset garbage collection threshold
runtime.GC() runtime.GC()