Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ coverage.xml

# uv
uv.lock
.uv-cache/

# 本地开发工具脚本
scripts/
Expand Down
17 changes: 17 additions & 0 deletions src/finchbot/cli_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
27 changes: 27 additions & 0 deletions tests/test_cli_main.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions uv.toml
Original file line number Diff line number Diff line change
@@ -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"