refactor: hide install-service from CLI help, keep as backward-compat alias
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.
This commit is contained in:
+7
-12
@@ -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()
|
||||
|
||||
+10
-11
@@ -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):
|
||||
with (
|
||||
patch("sys.argv", ["muxplex", "install-service"]),
|
||||
patch("muxplex.service.service_install") as mock_install,
|
||||
):
|
||||
main()
|
||||
except SystemExit:
|
||||
pass
|
||||
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user