Silence prune and snapshot removal status under --cron and --quiet (closes #294)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
PruneBlobs, CleanupLocalSnapshots, RemoveSnapshot, RemoveAllSnapshots and snapshot purge wrote their status lines straight to stdout, so `snapshot create --cron --prune` printed on every successful run and --quiet did not silence `prune`, `snapshot purge`, `snapshot remove` or `remote nuke`. Those lines now go through internal/ui, which drops them under --cron and --quiet; warnings, errors and --json documents still print. The confirmation prompts still write straight to stdout, as the `database delete` prompt does, together with what they ask to delete: the snapshot list before the purge prompt, and the blob count and size before the prune prompt. With --force those lines are status lines. The two purge test fixtures gained the UI writer production always sets. Model: opus-5-5
This commit was merged in pull request #369.
This commit is contained in:
@@ -204,7 +204,7 @@ func (v *Vaultik) PruneBlobs(opts *PruneOptions) error {
|
||||
return v.outputPruneBlobsJSON(result)
|
||||
}
|
||||
|
||||
v.printlnStdout("No unreferenced blobs to remove.")
|
||||
v.UI.Infof("No unreferenced blobs to remove.")
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -212,12 +212,17 @@ func (v *Vaultik) PruneBlobs(opts *PruneOptions) error {
|
||||
log.Info("Found unreferenced blobs",
|
||||
"count", len(unreferencedBlobs), "total_size", ubytes(totalSize))
|
||||
|
||||
if !opts.JSON {
|
||||
v.stdoutf("Found %d unreferenced blob(s) totaling %s\n",
|
||||
if opts.Force && !opts.JSON {
|
||||
v.UI.Infof("Found %d unreferenced blob(s) totaling %s.",
|
||||
len(unreferencedBlobs), ubytes(totalSize))
|
||||
}
|
||||
|
||||
if !opts.Force && !opts.JSON {
|
||||
// The count, the prompt and its answer bypass the UI: they are an
|
||||
// interactive exchange the operator must see, so --quiet does not
|
||||
// silence them.
|
||||
v.stdoutf("Found %d unreferenced blob(s) totaling %s.\n",
|
||||
len(unreferencedBlobs), ubytes(totalSize))
|
||||
v.stdoutf("\nDelete %d unreferenced blob(s)? [y/N] ", len(unreferencedBlobs))
|
||||
|
||||
var confirm string
|
||||
@@ -244,7 +249,7 @@ func (v *Vaultik) PruneBlobs(opts *PruneOptions) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
v.stdoutf("\nDeleted %d blob(s) totaling %s\n",
|
||||
v.UI.Infof("Deleted %d blob(s) totaling %s.",
|
||||
result.BlobsDeleted, ubytes(result.BytesFreed))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user