From 96d60624cbf78623516adbc54de4e74cbe13f4bb Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Mon, 22 Jan 2024 13:50:21 -0800 Subject: [PATCH] added /test cmd #335 --- aider/commands.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/aider/commands.py b/aider/commands.py index 117a33cca..e358a5abc 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -419,7 +419,12 @@ class Commands: self.io.tool_output(combined_output) - def cmd_run(self, args): + def cmd_test(self, args): + "Run a shell command and add the output to the chat on non-zero exit code" + + return self.cmd_run(args, True) + + def cmd_run(self, args, add_on_nonzero_exit=False): "Run a shell command and optionally add the output to the chat" combined_output = None try: @@ -441,7 +446,12 @@ class Commands: self.io.tool_output(combined_output) - if self.io.confirm_ask("Add the output to the chat?", default="y"): + if add_on_nonzero_exit: + add = result.returncode != 0 + else: + add = self.io.confirm_ask("Add the output to the chat?", default="y") + + if add: for line in combined_output.splitlines(): self.io.tool_output(line, log_only=True)