diff --git a/.gitignore b/.gitignore index a3c5722..75a060f 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ coverage.xml # uv uv.lock +.uv-cache/ # 本地开发工具脚本 scripts/ diff --git a/src/finchbot/cli_main.py b/src/finchbot/cli_main.py index 8a272d7..06f7d1e 100644 --- a/src/finchbot/cli_main.py +++ b/src/finchbot/cli_main.py @@ -191,6 +191,23 @@ def channel_serve( 启动 HTTP 服务接收 LangBot 的消息事件。 """ + _serve_webhook(host, port) + + +@app.command("webhook") +def webhook_serve( + host: str = typer.Option("0.0.0.0", "--host", "-h", help=t("cli.channel.host_help")), + port: int = typer.Option(8000, "--port", "-p", help=t("cli.channel.port_help")), +) -> None: + """启动 Webhook 服务器. + + 文档中公开的快捷命令,等价于 `finchbot channel serve`。 + """ + _serve_webhook(host, port) + + +def _serve_webhook(host: str, port: int) -> None: + """启动 LangBot Webhook 服务.""" from finchbot.channels.webhook_server import run_webhook_server from finchbot.config import load_config diff --git a/tests/test_cli_main.py b/tests/test_cli_main.py new file mode 100644 index 0000000..2376ced --- /dev/null +++ b/tests/test_cli_main.py @@ -0,0 +1,27 @@ +"""CLI command registration tests.""" + +from __future__ import annotations + +from typer.testing import CliRunner + +from finchbot.cli_main import app + +runner = CliRunner() + + +def test_webhook_command_is_registered() -> None: + """The documented `finchbot webhook` command should exist.""" + result = runner.invoke(app, ["webhook", "--help"]) + + assert result.exit_code == 0 + assert "--host" in result.output + assert "--port" in result.output + + +def test_channel_serve_command_remains_registered() -> None: + """The original nested command should stay available.""" + result = runner.invoke(app, ["channel", "serve", "--help"]) + + assert result.exit_code == 0 + assert "--host" in result.output + assert "--port" in result.output diff --git a/uv.toml b/uv.toml index 71d9467..c994700 100644 --- a/uv.toml +++ b/uv.toml @@ -1,4 +1,4 @@ # UV Configuration -# 缓存放在 D 盘 +# Keep uv's cache inside the repository so the config works across platforms. -cache-dir = "/Users/xjian/b_work/gitee_ky/FinchBot/uv" +cache-dir = ".uv-cache"