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()