Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion promptshell/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.1.0"
__version__ = "0.1.1"
4 changes: 2 additions & 2 deletions promptshell/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def main():
if len(prompt) + len(user_input) > columns:
print() # Move to the next line if input is too long

if user_input.lower() == 'quit':
if user_input.lower() in ('quit', 'exit'):
print(format_text('red', bold=True) + "\nTerminating..." + reset_format())
break

Expand All @@ -49,7 +49,7 @@ def main():
- Start your input with '!' to execute a command directly without processing.
- Start or end your input with '?' to ask a question.
- Tab completion for files and folders is enabled.
- Use 'Ctrl + c' or type 'quit' to quit the assistant.
-Use 'Ctrl + c' or type 'quit' or 'exit' to quit and exit the assistant.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 'Ctrl + c' or type 'quit' or 'exit' to quit and exit the assistant. Please change the 'and' to 'or'.

- Type 'clear' to clear the terminal.{reset_format()}""")
continue

Expand Down
27 changes: 27 additions & 0 deletions tests/test_repl_exit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
def run_repl_and_send_input(commands):
import subprocess

proc = subprocess.Popen(
['python3', '-m', 'promptshell.main'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
)
input_str = '\n'.join(commands) + '\n'
try:
stdout, stderr = proc.communicate(input=input_str, timeout=10)
except subprocess.TimeoutExpired:
proc.kill()
stdout, stderr = proc.communicate()
print("STDOUT:", stdout)
print("STDERR:", stderr)
return stdout, stderr, proc.returncode

def test_quit_command():
out, err, code = run_repl_and_send_input(["quit"])
assert "Terminating" in out or "Terminating" in err

def test_exit_command():
out, err, code = run_repl_and_send_input(["exit"])
assert "Terminating" in out or "Terminating" in err