MCPcopy
hub / github.com/HKUDS/DeepCode / format_single_command_result

Function format_single_command_result

tools/command_executor.py:266–298  ·  view source on GitHub ↗

格式化单命令执行结果 / 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
)

Source from the content-addressed store, hash-verified

264
265
266def 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
301async def main():

Callers 1

execute_single_commandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected