Skip to content

Commit 5088969

Browse files
committed
Add confirmation prompt before deletion
1 parent 9bcee8b commit 5088969

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

ollama_manager/commands/delete.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
default=False,
1616
is_flag=True,
1717
)
18-
def delete_model(multi: bool):
18+
@click.option(
19+
"--yes",
20+
"-y",
21+
help="Skip confirmation prompt for deletion",
22+
type=bool,
23+
default=False,
24+
is_flag=True,
25+
)
26+
def delete_model(multi: bool, yes: bool):
1927
"""
2028
Deletes the selected model/s
2129
"""
@@ -31,5 +39,16 @@ def delete_model(multi: bool):
3139
if selections:
3240
for selection in selections:
3341
normalized_selection = selection.split()[0]
34-
ollama.delete(normalized_selection)
42+
if not yes:
43+
confirm = input(
44+
f"Are you sure you want to delete '\033[91m{normalized_selection}\033[0m'? \n[y(yes) | n(no)] "
45+
)
46+
47+
if confirm.strip() in ("yes", "y"):
48+
ollama.delete(normalized_selection)
49+
else:
50+
print("❌ Exited delete mode.")
51+
sys.exit(0)
52+
else:
53+
ollama.delete(normalized_selection)
3554
print(f"🗑️ Deleted model: {normalized_selection}")

0 commit comments

Comments
 (0)