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..ef60a90 --- /dev/null +++ b/src/dwarffi/cli.py @@ -0,0 +1,25 @@ +# src/dwarffi/cli.py +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 + 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