mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 02:01:48 +03:00
fix(cli): preserve root shell completion
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from nanobot.cli import entry
|
||||
from nanobot.cli.entry import _agent_invocation_args, _native_tui_candidate
|
||||
|
||||
@@ -23,6 +28,36 @@ def test_root_metadata_and_subcommands_keep_the_root_cli() -> None:
|
||||
assert _agent_invocation_args(args) is None
|
||||
|
||||
|
||||
def test_root_shell_completion_keeps_root_subcommands() -> None:
|
||||
env = os.environ.copy()
|
||||
env.update(
|
||||
{
|
||||
"_NANOBOT_COMPLETE": "complete_bash",
|
||||
"COMP_WORDS": "nanobot ",
|
||||
"COMP_CWORD": "1",
|
||||
}
|
||||
)
|
||||
script = (
|
||||
"import sys; "
|
||||
"from nanobot.cli.entry import main; "
|
||||
"sys.argv = ['nanobot']; "
|
||||
"main()"
|
||||
)
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", script],
|
||||
cwd=Path(__file__).parents[2],
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert {"agent", "gateway", "webui"} <= set(result.stdout.splitlines())
|
||||
assert "not supported" not in result.stderr
|
||||
|
||||
|
||||
def test_root_alias_dispatches_the_shared_agent_command(monkeypatch) -> None:
|
||||
calls: dict[str, object] = {}
|
||||
monkeypatch.setattr(entry.sys, "argv", ["nanobot", "-m", "hello"])
|
||||
|
||||
Reference in New Issue
Block a user