重构第4批:入口注册 serve 命令,更新命令树和项目文档
__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 接口对照表 - 更新开发环境和工作规范
This commit is contained in:
1 parent
db378b9140
commit
9ec009f2cb
4 files changed
+171
-26
No files matched your search
+15
-2
@@ -1,9 +1,13 @@
|
||||
"""ekb-cli:快报命令行工具"""
|
||||
"""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",
|
||||
@@ -14,7 +18,16 @@ app = typer.Typer(
|
||||
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():
|
||||
app()
|
||||
"""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)
|
||||
Reference in new issue
Block a user