From 4994e853e015518a9dfc43fddd17879c86039c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Wed, 15 Nov 2023 10:57:48 +0800 Subject: [PATCH] :sparkles: Feature: add `reload-dirs` option to run project (#105) Co-authored-by: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> --- nb_cli/cli/commands/project.py | 12 ++++++++++++ nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po | 11 ++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/nb_cli/cli/commands/project.py b/nb_cli/cli/commands/project.py index cb1a575..b2343a1 100644 --- a/nb_cli/cli/commands/project.py +++ b/nb_cli/cli/commands/project.py @@ -325,6 +325,12 @@ async def generate(file: str): default=False, help=_("Reload the bot when file changed."), ) +@click.option( + "--reload-dirs", + multiple=True, + default=None, + help=_("Paths to watch for changes."), +) @click.option( "--reload-includes", multiple=True, @@ -348,6 +354,7 @@ async def generate(file: str): async def run( file: str, reload: bool, + reload_dirs: Optional[List[str]], reload_includes: Optional[List[str]], reload_excludes: Optional[List[str]], reload_delay: float, @@ -358,6 +365,11 @@ async def run( await Reloader( partial(run_project, exist_bot=Path(file)), terminate_process, + reload_dirs=( + [Path(i) for i in reload_dirs] + if reload_dirs is not None + else reload_dirs + ), file_filter=FileFilter(reload_includes, reload_excludes), reload_delay=reload_delay, cwd=get_project_root(), diff --git a/nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po b/nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po index b9ecd2e..d0a6287 100644 --- a/nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po +++ b/nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: nb-cli 1.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-10-29 07:13+0000\n" +"POT-Creation-Date: 2023-11-14 22:04+0800\n" "PO-Revision-Date: 2023-01-11 08:56+0000\n" "Last-Translator: FULL NAME \n" "Language: zh_Hans_CN\n" @@ -370,14 +370,18 @@ msgid "Reload the bot when file changed." msgstr "当文件发生变化时重新加载机器人." #: nb_cli/cli/commands/project.py:332 +msgid "Paths to watch for changes." +msgstr "要监视变化的路径." + +#: nb_cli/cli/commands/project.py:338 msgid "Files to watch for changes." msgstr "要监视变化的文件." -#: nb_cli/cli/commands/project.py:338 +#: nb_cli/cli/commands/project.py:344 msgid "Files to ignore for changes." msgstr "要忽略变化的文件." -#: nb_cli/cli/commands/project.py:345 +#: nb_cli/cli/commands/project.py:351 msgid "Delay time for reloading in seconds." msgstr "重新加载的延迟时间(秒)." @@ -460,3 +464,4 @@ msgstr "无效的模块类型: {module_type}" #: nb_cli/handlers/store.py:79 msgid "Failed to get {module_type} list." msgstr "获取 {module_type} 列表失败." +