mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-07 13:15:00 +00:00
feat: add printable_shell_command function for cross-platform command escaping
This commit is contained in:
parent
df7b181560
commit
89c9f5ccf9
1 changed files with 17 additions and 1 deletions
|
@ -8,6 +8,7 @@ import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import git
|
import git
|
||||||
|
import platform
|
||||||
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
from aider.run_cmd import run_cmd
|
from aider.run_cmd import run_cmd
|
||||||
|
@ -333,7 +334,22 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd):
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print("Install failed, try running this command manually:")
|
print("Install failed, try running this command manually:")
|
||||||
print(shlex.join(cmd))
|
print(printable_shell_command(cmd))
|
||||||
|
|
||||||
|
def printable_shell_command(cmd_list):
|
||||||
|
"""
|
||||||
|
Convert a list of command arguments to a properly shell-escaped string.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
cmd_list (list): List of command arguments.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Shell-escaped command string.
|
||||||
|
"""
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
return subprocess.list2cmdline(cmd_list)
|
||||||
|
else:
|
||||||
|
return shlex.join(cmd_list)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue