From b5f533874f61fbc051f03d88d9224a4b17799331 Mon Sep 17 00:00:00 2001 From: Orual Date: Mon, 23 Feb 2026 22:27:56 -0500 Subject: [PATCH] feat: add dfgraph package skeleton with CLI entry point --- dfgraph/__init__.py | 1 + dfgraph/__main__.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 dfgraph/__init__.py create mode 100644 dfgraph/__main__.py diff --git a/dfgraph/__init__.py b/dfgraph/__init__.py new file mode 100644 index 0000000..8c2ec92 --- /dev/null +++ b/dfgraph/__init__.py @@ -0,0 +1 @@ +"""Dataflow graph renderer for OR1 dfasm programs.""" diff --git a/dfgraph/__main__.py b/dfgraph/__main__.py new file mode 100644 index 0000000..6f98f11 --- /dev/null +++ b/dfgraph/__main__.py @@ -0,0 +1,39 @@ +"""CLI entry point: python -m dfgraph path/to/file.dfasm [--port 8420]""" + +import argparse +import sys +from pathlib import Path + + +def main() -> None: + parser = argparse.ArgumentParser( + prog="dfgraph", + description="Visualise a dfasm dataflow program as an interactive graph.", + ) + parser.add_argument( + "file", + type=Path, + help="Path to the .dfasm source file to visualise", + ) + parser.add_argument( + "--port", + type=int, + default=8420, + help="Port for the web server (default: 8420)", + ) + + args = parser.parse_args() + + if not args.file.exists(): + print(f"Error: file not found: {args.file}", file=sys.stderr) + sys.exit(1) + + if not args.file.suffix == ".dfasm": + print(f"Warning: expected .dfasm file, got: {args.file.suffix}", file=sys.stderr) + + # Server startup will be added in Phase 4 + print(f"dfgraph: would serve {args.file} on port {args.port}") + + +if __name__ == "__main__": + main() -- 2.51.2