Q2NSViz 0.1.0
Q2NS trace visualizer
Loading...
Searching...
No Matches
cli.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -----------------------------------------------------------------------------
3# Q2NSViz - Quantum Network Trace Visualizer
4# Copyright (c) 2026 QuantumInternet.it
5#
6# This program is released under the MIT License - see LICENSE for details.
7# -----------------------------------------------------------------------------
8
9import argparse
10import logging
11import sys
12
13from .ui.window import main as launch_gui
14
15
16def _build_parser() -> argparse.ArgumentParser:
17 parser = argparse.ArgumentParser(
18 prog="q2nsviz", description="Launch the Quantum Network Visualizer desktop viewer."
19 )
20 parser.add_argument(
21 "trace_file", nargs="?", help="Optional path to a .json or .ndjson trace file to load on startup."
22 )
23 parser.add_argument(
24 "--log-level",
25 default="WARNING",
26 choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
27 help="Python log verbosity for the viewer process.",
28 )
29 return parser
30
31
32def main(argv: list[str] | None = None) -> int:
33 args = _build_parser().parse_args(argv)
34 logging.basicConfig(level=getattr(logging, args.log_level), format="%(levelname)s [%(name)s] %(message)s")
35 return launch_gui(args.trace_file)
36
37
38if __name__ == "__main__":
39 sys.exit(main())