feat: update doctor() to show serve config and fix service install message
- Add serve config display in doctor() showing host, port, auth, and session_ttl from settings.json (inserted after Settings file block) - Update two 'not installed' messages from 'muxplex install-service' to 'muxplex service install' (macOS launchd and Linux systemd sections) - Add test_doctor_shows_serve_config verifying custom settings values (0.0.0.0, 9999, password) appear in doctor() output
This commit is contained in:
+11
-2
@@ -264,6 +264,15 @@ def doctor() -> None:
|
||||
f" {warn_mark} Settings: {SETTINGS_PATH} (not yet created — will use defaults)"
|
||||
)
|
||||
|
||||
# Serve config
|
||||
from muxplex.settings import load_settings # noqa: PLC0415
|
||||
|
||||
cfg = load_settings()
|
||||
print(
|
||||
f" {ok_mark} Serve config: {cfg['host']}:{cfg['port']}"
|
||||
f" (auth={cfg['auth']}, ttl={cfg['session_ttl']}s)"
|
||||
)
|
||||
|
||||
# Auth status
|
||||
pw_path = get_password_path()
|
||||
if pam_available():
|
||||
@@ -314,7 +323,7 @@ def doctor() -> None:
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f" {warn_mark} Service: not installed (run: muxplex install-service)"
|
||||
f" {warn_mark} Service: not installed (run: muxplex service install)"
|
||||
)
|
||||
else:
|
||||
systemd_user = Path.home() / ".config" / "systemd" / "user" / "muxplex.service"
|
||||
@@ -326,7 +335,7 @@ def doctor() -> None:
|
||||
)
|
||||
else:
|
||||
print(
|
||||
f" {warn_mark} Service: not installed (run: muxplex install-service)"
|
||||
f" {warn_mark} Service: not installed (run: muxplex service install)"
|
||||
)
|
||||
|
||||
print() # trailing newline
|
||||
|
||||
@@ -1003,3 +1003,25 @@ def test_help_shows_single_upgrade_line():
|
||||
"upgrade and update must appear as alias notation 'upgrade (update)', not two separate entries. "
|
||||
f"Got help text:\n{help_text}"
|
||||
)
|
||||
|
||||
|
||||
def test_doctor_shows_serve_config(tmp_path, monkeypatch, capsys):
|
||||
"""doctor() must show the current serve config (host, port, auth)."""
|
||||
import json
|
||||
|
||||
import muxplex.settings as settings_mod
|
||||
|
||||
settings_file = tmp_path / "settings.json"
|
||||
settings_file.write_text(
|
||||
json.dumps({"host": "0.0.0.0", "port": 9999, "auth": "password"})
|
||||
)
|
||||
monkeypatch.setattr(settings_mod, "SETTINGS_PATH", settings_file)
|
||||
|
||||
from muxplex.cli import doctor
|
||||
|
||||
doctor()
|
||||
|
||||
out = capsys.readouterr().out
|
||||
assert "0.0.0.0" in out
|
||||
assert "9999" in out
|
||||
assert "password" in out
|
||||
|
||||
Reference in New Issue
Block a user