Skip to content

Commit

Permalink
🍻 entari -> entari run
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Dec 14, 2024
1 parent 0be566c commit 26ddd5a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $ entari new
```
```shell
# 运行
$ entari
$ entari run
```

使用配置文件:
Expand All @@ -38,6 +38,8 @@ basic:
log_level: INFO
prefix: ["/"]
plugins:
$prelude:
- ::auto_reload
~record_message: true
::auto_reload:
watch_dirs: ["."]
Expand Down
14 changes: 10 additions & 4 deletions arclet/entari/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
alc = Alconna(
"entari",
Subcommand("new", help_text="新建一个 Entari 配置文件"),
Subcommand("run", help_text="运行 Entari"),
Option("-c|--config", Args["path/", str], help_text="指定配置文件路径"),
meta=CommandMeta(
"Entari App Launcher",
Expand All @@ -33,6 +34,7 @@
"prefix": ["/"]
},
"plugins": {
"$prelude": ["::auto_reload"],
"~record_message": true,
"::auto_reload": {
"watch_dirs": ["."]
Expand All @@ -55,6 +57,8 @@
log_level: "info"
prefix: ["/"]
plugins:
$prelude:
- ::auto_reload
~record_message: true
::auto_reload:
watch_dirs: ["."]
Expand All @@ -65,9 +69,9 @@

def main():
res = alc()
if not res.matched:
if not res.matched or res.non_component:
print(alc.get_help())
return
command_manager.delete(alc)
if res.find("new"):
if (path := res.query[str]("config.path", None)) is None:
if find_spec("yaml"):
Expand All @@ -91,5 +95,7 @@ def main():
return
print(f"Unsupported file extension: {_path.suffix}")
return
entari = Entari.load(res.query[str]("config.path", None))
entari.run()
if res.find("run"):
command_manager.delete(alc)
entari = Entari.load(res.query[str]("config.path", None))
entari.run()

0 comments on commit 26ddd5a

Please sign in to comment.