Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add reload-dirs option to run project #105

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nb_cli/cli/commands/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(),
Expand Down
11 changes: 8 additions & 3 deletions nb_cli/locale/zh_CN/LC_MESSAGES/nb-cli.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language: zh_Hans_CN\n"
Expand Down Expand Up @@ -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 "重新加载的延迟时间(秒)."

Expand Down Expand Up @@ -460,3 +464,4 @@ msgstr "无效的模块类型: {module_type}"
#: nb_cli/handlers/store.py:79
msgid "Failed to get {module_type} list."
msgstr "获取 {module_type} 列表失败."

Loading