Skip to content

Commit a8ba588

Browse files
committed
Integrate shell command execution in CLI and autocomplete support
In this commit, we've added a new feature to our CLI in `aicodebot/cli.py` that allows users to execute shell commands directly. This is done by typing `/sh` followed by the desired command. We've also ensured that empty commands are handled gracefully. In addition, we've updated the autocomplete functionality in `aicodebot/coder.py` to include the new `/sh` command. This will provide a smoother user experience when using the CLI. 🚀👩‍💻
1 parent fc74d5e commit a8ba588

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

aicodebot/cli.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,17 @@ def calc_response_token_size(files):
586586
ctx = click.get_current_context()
587587
ctx.invoke(review, *args)
588588
continue
589+
elif cmd == "/sh":
590+
# Strip off the /sh and any leading/trailing whitespace
591+
shell_command = human_input[3:].strip()
592+
593+
if not shell_command:
594+
continue
595+
596+
# Execute the shell command and let the output go directly to the console
597+
subprocess.run(shell_command, shell=True) # noqa: S602
598+
continue
599+
589600
elif cmd == "/quit":
590601
break
591602

aicodebot/coder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def get_completions(self, document, complete_event):
451451
# Get the text before the cursor
452452
text = document.text_before_cursor
453453

454-
supported_commands = ["/add", "/commit", "/drop", "/edit", "/files", "/review", "/quit"]
454+
supported_commands = ["/add", "/commit", "/drop", "/edit", "/files", "/review", "/sh", "/quit"]
455455

456456
# If the text starts with a slash, it's a command
457457
if text.startswith("/"):

0 commit comments

Comments
 (0)