init commit

初始提交,无事发生~
This commit is contained in:
2026-05-01 14:35:07 +08:00
commit f3442a1b61
46 changed files with 5751 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
"""
此文件为命令行入口。
避免在此文件中引用 router 模块内的代码。
"""
import typer
from rich.console import Console
from nyahome import __version__
console = Console()
app = typer.Typer(
name="Nya Home",
help="🌸 为你而存在的故事之家 ~",
rich_markup_mode="rich",
no_args_is_help=True,
)
def version_callback(value: bool = False) -> None:
if value:
console.print(f"[green]Nya Home[/green] version {__version__}")
@app.callback(invoke_without_command=True)
def main(
version: bool = typer.Option(
False,
"--version",
"-v",
help="显示版本号并退出,没有其他命令会被执行。",
callback=version_callback,
is_eager=True,
),
) -> None:
console.print("[bright_black]Nya Home 仍然处于极早期的阶段。如果遇到任何问题,请告诉芒果帆帆喵![/bright_black]")
@app.command()
def run() -> None:
"""
运行 Nya Home。
"""
import uvicorn
uvicorn.run(
"nyahome.server:app",
reload=True,
host="0.0.0.0",
port=9000,
timeout_graceful_shutdown=2,
)
if __name__ == "__main__":
app()