From e24a5c38344961a504e7006b01913e1f15a5ce63 Mon Sep 17 00:00:00 2001 From: Brian Krabach Date: Wed, 1 Apr 2026 01:55:26 -0700 Subject: [PATCH] refactor: hide install-service from CLI help, keep as backward-compat alias MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed install-service from argparse subparsers so it doesn't appear in the usage line or help listing. Intercepted before parse_args() for backward compatibility — prints deprecation warning and forwards to service install. --- muxplex/cli.py | 19 +++++++------------ muxplex/tests/test_cli.py | 23 +++++++++++------------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/muxplex/cli.py b/muxplex/cli.py index 96797ba..c369a3a 100644 --- a/muxplex/cli.py +++ b/muxplex/cli.py @@ -548,14 +548,6 @@ def main() -> None: serve_parser = sub.add_parser("serve", help="Start the server (default)") _add_serve_flags(serve_parser) - svc = sub.add_parser( - "install-service", - help="Install as a background service (systemd on Linux, launchd on macOS)", - ) - svc.add_argument( - "--system", action="store_true", help="System-wide (requires sudo)" - ) - service_parser = sub.add_parser( "service", help="Manage the muxplex background service" ) @@ -587,9 +579,8 @@ def main() -> None: help="Force reinstall even if already up to date", ) - args = parser.parse_args() - - if args.command == "install-service": + # Intercept deprecated 'install-service' before argparse sees it + if len(sys.argv) > 1 and sys.argv[1] == "install-service": print( "\u26a0 'muxplex install-service' is deprecated." " Use 'muxplex service install' instead.", @@ -598,7 +589,11 @@ def main() -> None: from muxplex.service import service_install # noqa: PLC0415 service_install() - elif args.command == "show-password": + return + + args = parser.parse_args() + + if args.command == "show-password": show_password() elif args.command == "reset-secret": reset_secret() diff --git a/muxplex/tests/test_cli.py b/muxplex/tests/test_cli.py index 709224b..3b1e104 100644 --- a/muxplex/tests/test_cli.py +++ b/muxplex/tests/test_cli.py @@ -191,21 +191,20 @@ def test_reset_secret_prints_warning(tmp_path, monkeypatch, capsys): ) -def test_install_service_help_text_mentions_background_service(): - """install-service help must mention 'service', not just 'systemd'.""" - import io +def test_install_service_deprecated_alias_prints_warning(capsys): + """install-service must print deprecation warning and forward to service install.""" from muxplex.cli import main - buf = io.StringIO() - with patch("sys.argv", ["muxplex", "install-service", "--help"]): - try: - with patch("sys.stdout", buf): - main() - except SystemExit: - pass + with ( + patch("sys.argv", ["muxplex", "install-service"]), + patch("muxplex.service.service_install") as mock_install, + ): + main() - help_text = buf.getvalue().lower() - assert "service" in help_text + captured = capsys.readouterr() + assert "deprecated" in captured.err.lower() + assert "service install" in captured.err.lower() + mock_install.assert_called_once() def test_check_dependencies_exits_when_ttyd_missing(monkeypatch):