diff --git a/README.md b/README.md index 78eaea7..2653d0c 100644 --- a/README.md +++ b/README.md @@ -359,7 +359,9 @@ on the destination in one go, use `vaultik remote nuke --force`. * `--local-only`: Skip remote cleanup; only touch the local index * `--dry-run`: Show what would be deleted without deleting * `--force`: Skip confirmation prompt -* `--json`: Output result as JSON +* `--json`: Output result as JSON. Also skips the confirmation prompt, as + `--force` does, so `snapshot remove --json ` removes without + asking. **`snapshot restore`**: Restore files from a backup snapshot. * Requires `VAULTIK_AGE_SECRET_KEY` environment variable @@ -383,7 +385,8 @@ manifests — network cost scales with the number of snapshots. `snapshot create --prune` runs the same cleanup automatically; this is the manual entry point for the same work. * `--force`: Skip confirmation prompt -* `--json`: Output stats as JSON +* `--json`: Output stats as JSON. Also skips the confirmation prompt, as + `--force` does, so `prune --json` deletes unreferenced blobs without asking. **`info`**: Display system configuration, storage settings, encryption recipients, and local database statistics. diff --git a/TODO.md b/TODO.md index fe962f5..809e3ba 100644 --- a/TODO.md +++ b/TODO.md @@ -22,6 +22,14 @@ the tag exists and is exercised; what is left is merging `next` to # Completed Steps +- 2026-10-07: Documented that `--json` skips the confirmation prompt of + `snapshot remove` and `prune` + ([issue #268](https://git.eeqj.de/sneak/vaultik/issues/268)). Both + commands delete without asking under `--json`, since a prompt on stdout + would break the JSON document, but the help and the README described + only `--force` as skipping it. The `--json` help of both commands and + their README entries now say so. + - 2026-10-07: Stopped a killed rclone upload from leaving a truncated object under its key ([issue #266](https://git.eeqj.de/sneak/vaultik/issues/266)). The diff --git a/internal/cli/json_help_test.go b/internal/cli/json_help_test.go new file mode 100644 index 0000000..3d25048 --- /dev/null +++ b/internal/cli/json_help_test.go @@ -0,0 +1,24 @@ +package cli //nolint:testpackage // exercises the unexported command constructor + +import ( + "testing" + + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" +) + +// TestJSONHelpSaysConfirmationPromptIsSkipped checks that the --json help +// of `snapshot remove` and `prune` says the flag skips the confirmation +// prompt. Both delete without asking under --json, since a prompt on +// stdout would break the JSON document. +func TestJSONHelpSaysConfirmationPromptIsSkipped(t *testing.T) { + t.Parallel() + + for _, cmd := range []*cobra.Command{ + newSnapshotRemoveCommand(), + NewPruneCommand(), + } { + assert.Contains(t, cmd.Flags().Lookup("json").Usage, + "skips the confirmation prompt", cmd.Name()) + } +} diff --git a/internal/cli/prune.go b/internal/cli/prune.go index e73d45d..707617b 100644 --- a/internal/cli/prune.go +++ b/internal/cli/prune.go @@ -57,7 +57,8 @@ referenced.`, } cmd.Flags().BoolVar(&opts.Force, "force", false, "Skip confirmation prompt") - cmd.Flags().BoolVar(&opts.JSON, "json", false, "Output pruning stats as JSON") + cmd.Flags().BoolVar(&opts.JSON, "json", false, + "Output pruning stats as JSON; skips the confirmation prompt, as --force does") return cmd } diff --git a/internal/cli/snapshot.go b/internal/cli/snapshot.go index a9c6e5a..58b32db 100644 --- a/internal/cli/snapshot.go +++ b/internal/cli/snapshot.go @@ -280,7 +280,8 @@ nuke --force' — it is the single supported entry point for that.`, cmd.Flags().BoolVarP(&opts.Force, "force", "f", false, "Skip confirmation prompt") cmd.Flags().BoolVar(&opts.DryRun, "dry-run", false, "Show what would be removed without removing") - cmd.Flags().BoolVar(&opts.JSON, "json", false, "Output result as JSON") + cmd.Flags().BoolVar(&opts.JSON, "json", false, + "Output result as JSON; skips the confirmation prompt, as --force does") cmd.Flags().BoolVar(&opts.LocalOnly, "local-only", false, "Skip remote cleanup; only touch the local index")