From 86aa53e3b0badc566a9f8fb124e963be6236eeee Mon Sep 17 00:00:00 2001 From: Justin Soderberg <723679+sodejm@users.noreply.github.com> Date: Mon, 20 Jul 2026 22:20:47 -0400 Subject: [PATCH] Remove legacy console CLI option Remove the special --legacy-console entry point so it follows normal parser error handling.\n\n- Preserve default REPL startup and one-shot command dispatch coverage.\n- Add regression coverage comparing --legacy-console with unsupported option behavior. --- src/ancestryllm/cli.py | 5 ----- tests/modular/test_repl_shell.py | 25 ++++++++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/ancestryllm/cli.py b/src/ancestryllm/cli.py index fbce9d0..b77289b 100644 --- a/src/ancestryllm/cli.py +++ b/src/ancestryllm/cli.py @@ -346,11 +346,6 @@ def run_tokens(context: AppContext, tokens: Sequence[str]) -> int: def main(argv: Sequence[str] | None = None, context: AppContext | None = None) -> int: arguments = list(sys.argv[1:] if argv is None else argv) - if arguments == ["--legacy-console"]: - from ancestryllm.console.app import AncestryConsole - - AncestryConsole(context or AppContext.build()).cmdloop() - return 0 if not arguments: from ancestryllm.console.shell import run_repl diff --git a/tests/modular/test_repl_shell.py b/tests/modular/test_repl_shell.py index dade4f9..3391e59 100644 --- a/tests/modular/test_repl_shell.py +++ b/tests/modular/test_repl_shell.py @@ -257,11 +257,10 @@ def fake_dispatch(namespace: argparse.Namespace, context: AppContext) -> int: assert worker_identifiers[0] != loop_identifier -def test_main_uses_default_shell_legacy_console_and_preserves_one_shot_dispatch( +def test_main_uses_default_shell_and_preserves_one_shot_dispatch( shell_module, app_context: AppContext, monkeypatch: pytest.MonkeyPatch ) -> None: import ancestryllm.cli as cli - from ancestryllm.console.app import AncestryConsole calls: list[str] = [] monkeypatch.setattr( @@ -269,7 +268,6 @@ def test_main_uses_default_shell_legacy_console_and_preserves_one_shot_dispatch( "run_repl", lambda context: calls.append(f"repl:{context is app_context}") or 17, ) - monkeypatch.setattr(AncestryConsole, "cmdloop", lambda _self: calls.append("legacy")) def one_shot(namespace: argparse.Namespace, context: AppContext) -> int: assert namespace.command == "modules" @@ -281,6 +279,23 @@ def one_shot(namespace: argparse.Namespace, context: AppContext) -> int: monkeypatch.setattr(cli, "dispatch", one_shot) assert cli.main([], app_context) == 17 - assert cli.main(["--legacy-console"], app_context) == 0 assert cli.main(["modules", "list"], app_context) == 29 - assert calls == ["repl:True", "legacy", "one-shot"] + assert calls == ["repl:True", "one-shot"] + + +def test_main_rejects_legacy_console_like_unknown_or_unsupported_options( + app_context: AppContext, capsys: pytest.CaptureFixture[str] +) -> None: + import ancestryllm.cli as cli + + with pytest.raises(SystemExit) as legacy_raised: + cli.main(["--legacy-console"], app_context) + legacy_error = capsys.readouterr().err + + with pytest.raises(SystemExit) as unsupported_raised: + cli.main(["--unsupported-option"], app_context) + unsupported_error = capsys.readouterr().err + + assert legacy_raised.value.code == unsupported_raised.value.code == 2 + assert "the following arguments are required: command" in legacy_error + assert legacy_error == unsupported_error.replace("--unsupported-option", "--legacy-console")