diff --git a/mediahive/__main__.py b/mediahive/__main__.py index dffcdb8..c3c4be6 100644 --- a/mediahive/__main__.py +++ b/mediahive/__main__.py @@ -54,9 +54,30 @@ def main() -> None: action="append", help=(f"Endpoint (default: localhost:{DEFAULT_PORT})."), ) + parser.add_argument( + "--gui", + action="store_true", + help="Run with GUI (fails if GUI dependencies are not installed)", + ) args = parser.parse_args() + # --listen implies server-only mode; use --gui to force GUI even with --listen. + use_gui = args.gui or not args.listen + + if use_gui: + try: + from mediahive.winmain import winmain + except ImportError as exc: + if args.gui: + raise RuntimeError( + "GUI dependencies are not installed. " + "Install with: uv pip install mediahive[gui]" + ) from exc + else: + winmain() + return + if args.media_folders: roots: dict[str, str] = {} for path in args.media_folders: diff --git a/mediahive/winmain.py b/mediahive/winmain.py index d877ec5..972c033 100644 --- a/mediahive/winmain.py +++ b/mediahive/winmain.py @@ -893,7 +893,7 @@ def winmain() -> None: nargs="?", help="Path to the media folder (default: saved config or initial setup dialog)", ) - args = parser.parse_args() + args, _unknown = parser.parse_known_args() _prepend_meipass_to_path()