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)")
|
serve_parser = sub.add_parser("serve", help="Start the server (default)")
|
||||||
_add_serve_flags(serve_parser)
|
_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_parser = sub.add_parser(
|
||||||
"service", help="Manage the muxplex background service"
|
"service", help="Manage the muxplex background service"
|
||||||
)
|
)
|
||||||
@@ -587,9 +579,8 @@ def main() -> None:
|
|||||||
help="Force reinstall even if already up to date",
|
help="Force reinstall even if already up to date",
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
# Intercept deprecated 'install-service' before argparse sees it
|
||||||
|
if len(sys.argv) > 1 and sys.argv[1] == "install-service":
|
||||||
if args.command == "install-service":
|
|
||||||
print(
|
print(
|
||||||
"\u26a0 'muxplex install-service' is deprecated."
|
"\u26a0 'muxplex install-service' is deprecated."
|
||||||
" Use 'muxplex service install' instead.",
|
" Use 'muxplex service install' instead.",
|
||||||
@@ -598,7 +589,11 @@ def main() -> None:
|
|||||||
from muxplex.service import service_install # noqa: PLC0415
|
from muxplex.service import service_install # noqa: PLC0415
|
||||||
|
|
||||||
service_install()
|
service_install()
|
||||||
elif args.command == "show-password":
|
return
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.command == "show-password":
|
||||||
show_password()
|
show_password()
|
||||||
elif args.command == "reset-secret":
|
elif args.command == "reset-secret":
|
||||||
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():
|
def test_install_service_deprecated_alias_prints_warning(capsys):
|
||||||
"""install-service help must mention 'service', not just 'systemd'."""
|
"""install-service must print deprecation warning and forward to service install."""
|
||||||
import io
|
|
||||||
from muxplex.cli import main
|
from muxplex.cli import main
|
||||||
|
|
||||||
buf = io.StringIO()
|
with (
|
||||||
with patch("sys.argv", ["muxplex", "install-service", "--help"]):
|
patch("sys.argv", ["muxplex", "install-service"]),
|
||||||
try:
|
patch("muxplex.service.service_install") as mock_install,
|
||||||
with patch("sys.stdout", buf):
|
):
|
||||||
main()
|
main()
|
||||||
except SystemExit:
|
|
||||||
pass
|
|
||||||
|
|
||||||
help_text = buf.getvalue().lower()
|
captured = capsys.readouterr()
|
||||||
assert "service" in help_text
|
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):
|
def test_check_dependencies_exits_when_ttyd_missing(monkeypatch):
|
||||||
|
|||||||
Reference in New Issue
Block a user