From 6e9afe3e54ab6fb0162393150b7892655b4561d4 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 24 Sep 2026 18:19:13 +0200 Subject: refactor(node): move the CLI out of daemon.py into cli/ Each `if args.command == ...` branch of main() becomes a function in cli/ (one module per family of verbs); the parser, the process setup and a VERBS table go to cli/parser.py and cli/dispatch.py. daemon.main runs the verb or starts the daemon. Tests patch the CLI through conftest.patch_cli; the CLI golden is unchanged. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-node/tests/test_cli_golden.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'packages/meshbay-node/tests/test_cli_golden.py') diff --git a/packages/meshbay-node/tests/test_cli_golden.py b/packages/meshbay-node/tests/test_cli_golden.py index ddaa82f..3d7b0c0 100644 --- a/packages/meshbay-node/tests/test_cli_golden.py +++ b/packages/meshbay-node/tests/test_cli_golden.py @@ -27,6 +27,8 @@ from meshbay_node import config as config_mod from meshbay_node import daemon as daemon_mod from test_cli_dispatch import VERBS +from conftest import patch_cli + GOLDEN = Path(__file__).parent / "golden" / "cli.json" # The verbs that ask first, asked and answered "no": test_cli_dispatch.py # passes --yes to all of them. @@ -78,9 +80,9 @@ def _run(argv: list[str], tmp_path: Path, capsys) -> dict: conf.write_text('[hub]\nurl = "https://example.invalid"\n') code = 0 with pytest.MonkeyPatch.context() as mp: - mp.setattr(daemon_mod, "_daemon_api", fake_api) - mp.setattr(daemon_mod, "_resolve_group", lambda cfg, g: "g" * 32) - mp.setattr(daemon_mod, "DEFAULT_CONFIG_PATH", conf) + patch_cli(mp, "_daemon_api", fake_api) + patch_cli(mp, "_resolve_group", lambda cfg, g: "g" * 32) + patch_cli(mp, "DEFAULT_CONFIG_PATH", conf) # The data directory and the keystore's default path come from these; # left real, `status` would record the developer's own node. mp.setenv("HOME", str(tmp_path / "home")) -- cgit v1.2.3