__init__.py: - 注册 serve 命令(ekb serve) - main() 统一捕获 EkbError,rich 红字输出并 SystemExit(1) commands/serve.py(新建): - ekb serve --host --port --reload - 启动 FastAPI + uvicorn commands/help.py: - 命令树补 serve 分支 CLAUDE.md: - 更新架构分层说明(三层:表现 / 业务 / 传输) - 更新完整项目结构 - 新增 CLI ↔ HTTP Server 接口对照表 - 更新开发环境和工作规范
34 lines
839 B
Python
34 lines
839 B
Python
"""ekb-cli:快报命令行工具
|
|
|
|
入口:注册所有命令组,统一捕获 EkbError 异常。
|
|
"""
|
|
|
|
import typer
|
|
from ekb_cli.commands import auth
|
|
from ekb_cli.commands.agent import app as agent_app
|
|
from ekb_cli.commands.help import cmd_commands
|
|
from ekb_cli.commands.serve import cmd_serve
|
|
|
|
app = typer.Typer(
|
|
name="ekb",
|
|
help="快报(ekuaibao)命令行工具",
|
|
no_args_is_help=True,
|
|
)
|
|
|
|
app.add_typer(auth.app, name="auth")
|
|
app.add_typer(agent_app, name="agent")
|
|
app.command("commands")(cmd_commands)
|
|
app.command("serve")(cmd_serve)
|
|
|
|
|
|
def main():
|
|
"""CLI 入口:统一捕获 EkbError,输出友好错误信息"""
|
|
from ekb_cli.errors import EkbError
|
|
from rich import print as rprint
|
|
|
|
try:
|
|
app()
|
|
except EkbError as e:
|
|
rprint(f"[red]{e.message}[/red]")
|
|
raise SystemExit(1)
|