Skip to content

Commit 41f8386

Browse files
committed
feat: support both 'exit' and 'quit' commands in REPL
1 parent 8eea874 commit 41f8386

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

promptshell/main.py

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def main():
3232
if len(prompt) + len(user_input) > columns:
3333
print() # Move to the next line if input is too long
3434

35-
# Support both 'quit' and 'exit' commands to terminate the REPL session
36-
if user_input.lower() in ('quit', 'exit'):
35+
if user_input.lower() in ('quit', 'exit'):
3736
print(format_text('red', bold=True) + "\nTerminating..." + reset_format())
3837
break
3938

@@ -50,30 +49,12 @@ def main():
5049
- Start your input with '!' to execute a command directly without processing.
5150
- Start or end your input with '?' to ask a question.
5251
- Tab completion for files and folders is enabled.
53-
- Use 'Ctrl + c' or type 'quit' or 'exit' to quit the assistant.
52+
-Use 'Ctrl + c' or type 'quit' or 'exit' to quit and exit the assistant.
5453
- Type 'clear' to clear the terminal.{reset_format()}""")
5554
continue
5655

57-
# ✅ Check for destructive command
58-
if user_input.startswith("CONFIRM:"):
59-
actual_command = user_input.replace("CONFIRM:", "", 1).strip()
60-
61-
# Step 1: Initial yes/no confirmation
62-
proceed = input(format_text('yellow', bold=True) + f"\n⚠️ This is a destructive command.\nDo you want to continue? (yes/no): " + reset_format())
63-
if proceed.strip().lower() != "yes":
64-
print(format_text('red', bold=True) + "\nCommand aborted by user." + reset_format())
65-
continue
66-
67-
# Step 2: Manual re-entry for safety
68-
confirm_input = input(format_text('yellow', bold=True) + f"Type the exact command to proceed:\n> " + reset_format())
69-
if confirm_input.strip() != actual_command:
70-
print(format_text('red', bold=True) + "\n❌ Mismatch. Aborting execution!" + reset_format())
71-
continue
72-
73-
# If matched, allow execution
74-
user_input = actual_command
75-
76-
result = assistant.execute_command(user_input) # Execute the command using the assistant
56+
result = assistant.execute_command(user_input)
57+
print(result)
7758

7859
except KeyboardInterrupt:
7960
print(format_text('red', bold=True) + "\nTerminating..." + reset_format())

0 commit comments

Comments
 (0)