From bff38fbd68ef8b0fb07ef8d988de73eeaf2af886 Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Thu, 7 May 2026 22:34:33 -0400 Subject: [PATCH 1/2] dwarffi: add cli available dwarf2json --- pyproject.toml | 5 ++++- src/dwarffi/cli.py | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/dwarffi/cli.py diff --git a/pyproject.toml b/pyproject.toml index 237b624..a4ed5b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,4 +85,7 @@ warn_unused_ignores = true [[tool.mypy.overrides]] module = "dwarffi._version" -ignore_missing_imports = true \ No newline at end of file +ignore_missing_imports = true + +[project.scripts] +dwarf2json = "dwarffi.cli:main" \ No newline at end of file diff --git a/src/dwarffi/cli.py b/src/dwarffi/cli.py new file mode 100644 index 0000000..4daa7d3 --- /dev/null +++ b/src/dwarffi/cli.py @@ -0,0 +1,24 @@ +# src/dwarffi/cli.py +import sys +import subprocess +from pathlib import Path + +def main() -> None: + """Entry point for the dwarf2json command line wrapper.""" + # Resolve the path to the bundled binary relative to this Python file + package_dir = Path(__file__).parent + + # Handle the `.exe` extension for Windows environments + exe_name = "dwarf2json.exe" if sys.platform == "win32" else "dwarf2json" + binary_path = package_dir / "bin" / exe_name + + if not binary_path.exists(): + print(f"Error: Bundled dwarf2json binary not found at {binary_path}", file=sys.stderr) + sys.exit(1) + + # Execute the binary, passing all arguments provided by the user + try: + result = subprocess.run([str(binary_path)] + sys.argv[1:]) + sys.exit(result.returncode) + except KeyboardInterrupt: + sys.exit(130) \ No newline at end of file From 0423acc7be07e77d576209bf4594debeb2d8707e Mon Sep 17 00:00:00 2001 From: Luke Craig Date: Thu, 7 May 2026 22:37:45 -0400 Subject: [PATCH 2/2] cli: ruff --- src/dwarffi/cli.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dwarffi/cli.py b/src/dwarffi/cli.py index 4daa7d3..ef60a90 100644 --- a/src/dwarffi/cli.py +++ b/src/dwarffi/cli.py @@ -1,8 +1,9 @@ # src/dwarffi/cli.py -import sys import subprocess +import sys from pathlib import Path + def main() -> None: """Entry point for the dwarf2json command line wrapper.""" # Resolve the path to the bundled binary relative to this Python file