Source code for simvx.editor.cli
"""The editor's command line, shared by ``simvx editor`` and the ``simvx-editor`` script.
Both spellings take the same arguments: an optional positional ``PATH`` naming the project
directory or file to open, and ``--backend`` to pick the windowing backend.
"""
import argparse
[docs]
def add_arguments(parser: argparse.ArgumentParser) -> None:
"""Declare the editor's arguments on *parser*."""
parser.add_argument(
"path",
nargs="?",
default=None,
metavar="PATH",
help="project directory or file to open, skipping the welcome screen",
)
parser.add_argument("--backend", default=None, help="windowing backend (sdl3, glfw or qt; default: auto-detect)")
[docs]
def run(args: argparse.Namespace) -> int:
"""Launch the editor from parsed arguments."""
from simvx.editor import launch
launch(project_path=args.path, backend=args.backend)
return 0
[docs]
def register(subparsers: argparse._SubParsersAction) -> None:
"""Attach ``editor`` to the ``simvx`` CLI."""
parser = subparsers.add_parser("editor", help="Launch the SimVX visual editor")
add_arguments(parser)
parser.set_defaults(func=run)