Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/ancestryllm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update docs before dropping legacy console flag

Now that non-empty arguments always fall through to the normal parser path here, ancestry --legacy-console exits with a usage error, but the shipped docs still advertise that exact command as the temporary cmd2 compatibility fallback in docs/CONSOLE.md:10-18 and docs/REPL_ARCHITECTURE.md:18-19,87-108. Users following those docs will lose the documented fallback, so the removal should update or delete those compatibility-path sections in the same change.

Useful? React with 👍 / 👎.

from ancestryllm.console.shell import run_repl

Expand Down
25 changes: 20 additions & 5 deletions tests/modular/test_repl_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,17 @@ 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(
shell_module,
"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"
Expand All @@ -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")
Loading