Skip to content

Commit bf7f627

Browse files
committed
prune: make dry-run the default, require --force to delete
Change the prune command to be safe by default. Running 'tk prune' now previews what would be deleted without actually deleting anything. Users must pass -f/--force to confirm the destructive operation.
1 parent adb244e commit bf7f627

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- `prune` command to delete old closed tickets
88
- `--days=N` to set age threshold (default: 7 days)
99
- `--all` to prune regardless of age
10-
- `--dry-run` to preview without deleting
10+
- `-f/--force` to actually delete (dry-run preview by default)
1111
- `closed_at` timestamp field set when tickets are closed
1212
- Dependency protection: closed tickets referenced by open/in-progress tickets are never pruned
1313

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ Commands:
101101
ready List open/in-progress tickets with deps resolved
102102
blocked List open/in-progress tickets with unresolved deps
103103
closed [--limit=N] List recently closed tickets (default 20, by mtime)
104-
prune [options] Delete old closed tickets
104+
prune [options] Delete old closed tickets (dry-run by default)
105105
--days=N Only prune tickets closed > N days ago [default: 7]
106106
--all Prune all eligible closed tickets
107-
--dry-run Preview what would be deleted
107+
-f, --force Actually delete (default is dry-run preview)
108108
show <id> Display ticket
109109
edit <id> Open ticket in $EDITOR
110110
add-note <id> [text] Append timestamped note (or pipe via stdin)

ticket

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ cmd_prune() {
12091209

12101210
local days=7
12111211
local prune_all=0
1212-
local dry_run=0
1212+
local force=0
12131213

12141214
# Parse arguments
12151215
while [[ $# -gt 0 ]]; do
@@ -1227,13 +1227,13 @@ cmd_prune() {
12271227
prune_all=1
12281228
shift
12291229
;;
1230-
--dry-run)
1231-
dry_run=1
1230+
-f|--force)
1231+
force=1
12321232
shift
12331233
;;
12341234
*)
12351235
echo "Error: unknown option '$1'" >&2
1236-
echo "Usage: $(basename "$0") prune [--days=N] [--all] [--dry-run]" >&2
1236+
echo "Usage: $(basename "$0") prune [--days=N] [--all] [--force]" >&2
12371237
return 1
12381238
;;
12391239
esac
@@ -1325,11 +1325,11 @@ cmd_prune() {
13251325

13261326
# Output the ticket info
13271327
local prefix=""
1328-
[[ "$dry_run" -eq 1 ]] && prefix="[DRY-RUN] "
1328+
[[ "$force" -eq 0 ]] && prefix="[DRY-RUN] "
13291329
echo "${prefix}${id}: $title (closed $closed_display)"
13301330

1331-
# Delete unless dry-run
1332-
if [[ "$dry_run" -eq 0 ]]; then
1331+
# Delete only if --force is set
1332+
if [[ "$force" -eq 1 ]]; then
13331333
rm "$filepath"
13341334
fi
13351335

@@ -1338,8 +1338,8 @@ cmd_prune() {
13381338

13391339
# Summary line
13401340
if [[ "$count" -gt 0 ]]; then
1341-
if [[ "$dry_run" -eq 1 ]]; then
1342-
echo "Would prune $count tickets"
1341+
if [[ "$force" -eq 0 ]]; then
1342+
echo "Would prune $count tickets (use --force to delete)"
13431343
else
13441344
echo "Pruned $count tickets"
13451345
fi
@@ -1379,10 +1379,10 @@ Commands:
13791379
ready List open/in-progress tickets with deps resolved
13801380
blocked List open/in-progress tickets with unresolved deps
13811381
closed [--limit=N] List recently closed tickets (default 20, by mtime)
1382-
prune [options] Delete old closed tickets
1382+
prune [options] Delete old closed tickets (dry-run by default)
13831383
--days=N Only prune tickets closed > N days ago [default: 7]
13841384
--all Prune all eligible closed tickets
1385-
--dry-run Preview what would be deleted
1385+
-f, --force Actually delete (default is dry-run preview)
13861386
show <id> Display ticket
13871387
edit <id> Open ticket in \$EDITOR
13881388
add-note <id> [text] Append timestamped note (or pipe via stdin)

0 commit comments

Comments
 (0)