Skip to content

Commit 6fbc9a5

Browse files
authored
Merge pull request #1169 from Vikranth3140/main
Add `--sysinfo` CLI Argument to Output System Information for Debugging
2 parents 55514c6 + 30d9f5b commit 6fbc9a5

File tree

1 file changed

+44
-0
lines changed
  • gpt_engineer/applications/cli

1 file changed

+44
-0
lines changed

gpt_engineer/applications/cli/main.py

+44
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
"""
2727

2828
import difflib
29+
import json
2930
import logging
3031
import os
32+
import platform
33+
import subprocess
3134
import sys
3235

3336
from pathlib import Path
@@ -237,6 +240,34 @@ def prompt_yesno() -> bool:
237240
print("Please respond with 'y' or 'n'")
238241

239242

243+
def get_system_info():
244+
system_info = {
245+
"os": platform.system(),
246+
"os_version": platform.version(),
247+
"architecture": platform.machine(),
248+
"python_version": sys.version,
249+
"packages": format_installed_packages(get_installed_packages()),
250+
}
251+
return system_info
252+
253+
254+
def get_installed_packages():
255+
try:
256+
result = subprocess.run(
257+
[sys.executable, "-m", "pip", "list", "--format=json"],
258+
capture_output=True,
259+
text=True,
260+
)
261+
packages = json.loads(result.stdout)
262+
return {pkg["name"]: pkg["version"] for pkg in packages}
263+
except Exception as e:
264+
return str(e)
265+
266+
267+
def format_installed_packages(packages):
268+
return "\n".join([f"{name}: {version}" for name, version in packages.items()])
269+
270+
240271
@app.command(
241272
help="""
242273
GPT-engineer lets you:
@@ -331,6 +362,11 @@ def main(
331362
"--no_execution",
332363
help="Run setup but to not call LLM or write any code. For testing purposes.",
333364
),
365+
sysinfo: bool = typer.Option(
366+
False,
367+
"--sysinfo",
368+
help="Output system information for debugging",
369+
),
334370
):
335371
"""
336372
The main entry point for the CLI tool that generates or improves a project.
@@ -371,6 +407,8 @@ def main(
371407
Flag indicating whether to enable verbose logging.
372408
no_execution: bool
373409
Run setup but to not call LLM or write any code. For testing purposes.
410+
sysinfo: bool
411+
Flag indicating whether to output system information for debugging.
374412
375413
Returns
376414
-------
@@ -382,6 +420,12 @@ def main(
382420

383421
sys.excepthook = lambda *_: pdb.pm()
384422

423+
if sysinfo:
424+
sys_info = get_system_info()
425+
for key, value in sys_info.items():
426+
print(f"{key}: {value}")
427+
raise typer.Exit()
428+
385429
# Validate arguments
386430
if improve_mode and (clarify_mode or lite_mode):
387431
typer.echo("Error: Clarify and lite mode are not compatible with improve mode.")

0 commit comments

Comments
 (0)