Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit 1f7c8e9

Browse files
confirm overwrite dest, switch to click.confirm()
1 parent c248873 commit 1f7c8e9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

bak/commands/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,20 @@ def bak_down_cmd(filename: Path,
254254
elif not bakfile_entry:
255255
return
256256
if not destination:
257-
destination = bakfile_entry.orig_abspath
257+
destination = Path(bakfile_entry.orig_abspath).expanduser()
258258

259259
if quiet:
260260
confirm = 'y'
261261
else:
262-
confirm_prompt = f"Confirm: Restore {filename} to {destination} and erase bakfiles?\n" \
262+
if destination != bakfile_entry.orig_abspath:
263+
if destination.exists():
264+
confirm = click.confirm(f"Overwrite {destination}?")
265+
266+
confirm_prompt = f"Confirm: Restore {filename} to {destination} and erase bakfiles?" \
263267
if not keep_bakfile else \
264-
f"Confirm: Restore {filename} to {destination} and keep bakfiles?\n"
265-
confirm_prompt += "(y/n)"
266-
confirm = click.prompt(confirm_prompt, default='n')
267-
if confirm.lower()[0] != 'y':
268+
f"Confirm: Restore {filename} to {destination} and keep bakfiles?"
269+
confirm = click.confirm(confirm_prompt, default=False)
270+
if not confirm:
268271
console.print("Cancelled.")
269272
return
270273
if not keep_bakfile:

0 commit comments

Comments
 (0)