| 2909 | |
| 2910 | |
| 2911 | def build_parser() -> argparse.ArgumentParser: |
| 2912 | parser = argparse.ArgumentParser(description="fastgrind binary trace tooling") |
| 2913 | subparsers = parser.add_subparsers(dest="command") |
| 2914 | |
| 2915 | inspect_parser = subparsers.add_parser("inspect", help="Inspect a fastgrind binary trace") |
| 2916 | inspect_parser.add_argument("path", nargs="?", help="Path to fastgrind.fgb") |
| 2917 | |
| 2918 | ui_parser = subparsers.add_parser("ui", help="Launch the Python-first UI") |
| 2919 | ui_parser.add_argument("path", nargs="?", help="Path to fastgrind.fgb") |
| 2920 | ui_parser.add_argument("--no-browser", action="store_true", help="Do not open a browser when ui falls back to html mode") |
| 2921 | ui_parser.add_argument("--port", type=int, default=0, help="Fallback HTTP port when ui degrades to html mode") |
| 2922 | |
| 2923 | html_parser = subparsers.add_parser("html", help="Serve the browser viewer") |
| 2924 | html_parser.add_argument("path", nargs="?", help="Path to fastgrind.fgb") |
| 2925 | html_parser.add_argument("--port", type=int, default=0, help="HTTP port, 0 for an ephemeral port") |
| 2926 | html_parser.add_argument("--no-browser", action="store_true", help="Serve without opening a browser") |
| 2927 | |
| 2928 | export_html_parser = subparsers.add_parser("export-html", help="Write a compact HTML snapshot") |
| 2929 | export_html_parser.add_argument("path", nargs="?", help="Path to fastgrind.fgb") |
| 2930 | export_html_parser.add_argument("-o", "--output", help="Output HTML path") |
| 2931 | |
| 2932 | export_json_parser = subparsers.add_parser("export-json", help="Regenerate compatibility JSON") |
| 2933 | export_json_parser.add_argument("path", nargs="?", help="Path to fastgrind.fgb") |
| 2934 | export_json_parser.add_argument("-o", "--output", help="Output JSON path") |
| 2935 | |
| 2936 | return parser |
| 2937 | |
| 2938 | |
| 2939 | def normalize_argv(argv: Sequence[str]) -> list[str]: |