1 Commits
Author SHA1 Message Date
sneak 71a232d0f7 Exit 1 when a deletion prompt is not confirmed (closes #423)
check / check (push) Successful in 9m27s
`prune`, `snapshot purge`, `snapshot remove` and `database delete`
printed "Cancelled" or "Aborted." and exited 0 when the prompt was
answered no or stdin ended. They now return vaultik.ErrNotConfirmed,
so the command reports "deletion not confirmed" and exits 1.

`database delete` reads its answer from the command's stdin instead of
os.Stdin, so a test can supply it.

Model: opus-5-5
2026-11-11 01:19:06 +00:00
2 changed files with 1208 additions and 7 deletions

No files matched your search

+1205 -3
View File
File diff suppressed because it is too large. Load diff
+3 -4
View File
@@ -185,10 +185,9 @@ func (v *Vaultik) printlnStdout(args ...any) {
_, _ = fmt.Fprintln(v.Stdout, args...)
}
// ErrNotConfirmed is returned when a confirmation prompt gets any answer
// but the one it asks for (`y` or `Y`, or `yes` for `database delete`), or
// stdin ends first. Nothing the prompt asked about is deleted, and the
// command exits non-zero.
// ErrNotConfirmed is returned when the operator answers a confirmation
// prompt with anything but yes, or stdin ends before an answer. Nothing
// the prompt asked about is deleted, and the command exits non-zero.
var ErrNotConfirmed = errors.New("deletion not confirmed")
// scanStdin reads a line of input from stdin.