mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
feat: Update cmd_run to use run_interactive_command
This commit is contained in:
parent
27e8780cbe
commit
46ce049777
1 changed files with 3 additions and 16 deletions
|
@ -15,7 +15,7 @@ from aider import models, prompts, voice
|
||||||
from aider.help import Help, install_help_extra
|
from aider.help import Help, install_help_extra
|
||||||
from aider.llm import litellm
|
from aider.llm import litellm
|
||||||
from aider.scrape import Scraper, install_playwright
|
from aider.scrape import Scraper, install_playwright
|
||||||
from aider.utils import is_image_file
|
from aider.utils import is_image_file, run_interactive_command
|
||||||
|
|
||||||
from .dump import dump # noqa: F401
|
from .dump import dump # noqa: F401
|
||||||
|
|
||||||
|
@ -722,21 +722,8 @@ class Commands:
|
||||||
|
|
||||||
def cmd_run(self, args, add_on_nonzero_exit=False):
|
def cmd_run(self, args, add_on_nonzero_exit=False):
|
||||||
"Run a shell command and optionally add the output to the chat (alias: !)"
|
"Run a shell command and optionally add the output to the chat (alias: !)"
|
||||||
combined_output = None
|
exit_status, combined_output = run_interactive_command(args)
|
||||||
instructions = None
|
instructions = None
|
||||||
try:
|
|
||||||
result = subprocess.run(
|
|
||||||
args,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
text=True,
|
|
||||||
shell=True,
|
|
||||||
encoding=self.io.encoding,
|
|
||||||
errors="replace",
|
|
||||||
)
|
|
||||||
combined_output = result.stdout
|
|
||||||
except Exception as e:
|
|
||||||
self.io.tool_error(f"Error running command: {e}")
|
|
||||||
|
|
||||||
if combined_output is None:
|
if combined_output is None:
|
||||||
return
|
return
|
||||||
|
@ -744,7 +731,7 @@ class Commands:
|
||||||
self.io.tool_output(combined_output)
|
self.io.tool_output(combined_output)
|
||||||
|
|
||||||
if add_on_nonzero_exit:
|
if add_on_nonzero_exit:
|
||||||
add = result.returncode != 0
|
add = exit_status != 0
|
||||||
else:
|
else:
|
||||||
response = self.io.prompt_ask(
|
response = self.io.prompt_ask(
|
||||||
"Add the output to the chat?\n[Y/n/instructions]",
|
"Add the output to the chat?\n[Y/n/instructions]",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue