格式化单命令执行结果 / Format single command execution result Args: command: 执行的命令 / Executed command working_directory: 工作目录 / Working directory result: 执行结果 / Execution result Returns: 格式化的结果 / Formatted result
(
command: str, working_directory: str, result: subprocess.CompletedProcess
)
| 264 | |
| 265 | |
| 266 | def format_single_command_result( |
| 267 | command: str, working_directory: str, result: subprocess.CompletedProcess |
| 268 | ) -> str: |
| 269 | """ |
| 270 | 格式化单命令执行结果 / Format single command execution result |
| 271 | |
| 272 | Args: |
| 273 | command: 执行的命令 / Executed command |
| 274 | working_directory: 工作目录 / Working directory |
| 275 | result: 执行结果 / Execution result |
| 276 | |
| 277 | Returns: |
| 278 | 格式化的结果 / Formatted result |
| 279 | """ |
| 280 | output = f""" |
| 281 | 单命令执行 / Single Command Execution: |
| 282 | {'='*40} |
| 283 | 工作目录 / Working Directory: {working_directory} |
| 284 | 命令 / Command: {command} |
| 285 | 返回码 / Return Code: {result.returncode} |
| 286 | |
| 287 | """ |
| 288 | |
| 289 | if result.returncode == 0: |
| 290 | output += "✅ 状态 / Status: SUCCESS / 成功\n" |
| 291 | if result.stdout.strip(): |
| 292 | output += f"输出 / Output:\n{result.stdout.strip()}\n" |
| 293 | else: |
| 294 | output += "❌ 状态 / Status: FAILED / 失败\n" |
| 295 | if result.stderr.strip(): |
| 296 | output += f"错误 / Error:\n{result.stderr.strip()}\n" |
| 297 | |
| 298 | return output |
| 299 | |
| 300 | |
| 301 | async def main(): |
no outgoing calls
no test coverage detected