feat(cli): 实现 nyahome config 命令
允许通过 nyahome 终端命令修改设置 同时再次调整数据库有关的内部常量的位置
This commit is contained in:
+17
-4
@@ -12,6 +12,7 @@ from rich.table import Table
|
||||
from nyahome import __version__
|
||||
from nyahome.cli.cli import console
|
||||
from nyahome.cli.cli_aii import aii_app
|
||||
from nyahome.cli.cli_config import config_app
|
||||
from nyahome.cli.cli_env import ENV_PATH, env_app
|
||||
|
||||
app = typer.Typer(
|
||||
@@ -38,7 +39,7 @@ def main(
|
||||
is_eager=True,
|
||||
),
|
||||
) -> None:
|
||||
console.print("[bright_black]NyaHome 仍然处于极早期的阶段。如果遇到任何问题,请告诉芒果帆帆喵![/bright_black]")
|
||||
console.print("(!) [bright_black]NyaHome 仍然处于极早期的阶段。如果遇到任何问题,请告诉芒果帆帆喵![/bright_black]")
|
||||
|
||||
|
||||
@app.command()
|
||||
@@ -91,7 +92,8 @@ def init() -> None:
|
||||
|
||||
from nyahome.cli.cli import DATA_DIR, ENV_PATH, LOGGING_YAML
|
||||
from nyahome.cli.cli_check import LOGGING_YAML_CONTENT
|
||||
from nyahome.database.engine import db_driver_available, db_type_allowlist
|
||||
from nyahome.config import config_manager
|
||||
from nyahome.data import db_driver_available, db_type_allowlist
|
||||
|
||||
console.print("\n准备初始化 NyaHome。")
|
||||
|
||||
@@ -153,6 +155,16 @@ def init() -> None:
|
||||
set_key(ENV_PATH, "NYAHOME_UVICORN_RELOAD", "true" if un_reload else "false")
|
||||
console.print("已设置 uvicorn 启动配置。")
|
||||
|
||||
# 4.NyaHome 设置初始化
|
||||
console.print("\n4. NyaHome 设置初始化")
|
||||
try:
|
||||
config_manager.sync_load_config()
|
||||
except FileNotFoundError:
|
||||
console.print("配置文件 [cyan].nyahome/config.json[/cyan] 不存在,创建默认配置。")
|
||||
config_manager.sync_save_config()
|
||||
else:
|
||||
console.print("配置文件已存在,跳过。")
|
||||
|
||||
|
||||
@app.command()
|
||||
def check() -> None:
|
||||
@@ -203,8 +215,9 @@ def check() -> None:
|
||||
console.print(f"\n[yellow]完成自检,共有 {cw.counter} 个警告。[/yellow]")
|
||||
|
||||
|
||||
app.add_typer(env_app, name="env", no_args_is_help=True, help="设置 NyaHome 应用的环境变量。")
|
||||
app.add_typer(aii_app, name="aii", no_args_is_help=True, help="添加、设置、修改 AI 提供商和模型。")
|
||||
app.add_typer(config_app, name="config", no_args_is_help=True, help="设置 NyaHome 的设置。(需要初始化)")
|
||||
app.add_typer(env_app, name="env", no_args_is_help=True, help="设置 NyaHome 应用的环境变量。(需要初始化)")
|
||||
app.add_typer(aii_app, name="aii", no_args_is_help=True, help="添加、设置、修改 AI 提供商和模型。(需要初始化)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user