1
1
#!/usr/bin/env python3
2
2
# -*- coding: utf-8 -*-
3
+ import asyncio
3
4
import os
4
5
5
6
from dataclasses import dataclass
14
15
from backend import console , get_version
15
16
from backend .common .exception .errors import BaseExceptionMixin
16
17
from backend .core .conf import settings
17
- from backend .utils ._await import run_await
18
18
from backend .utils .file_ops import install_git_plugin , install_zip_plugin
19
19
20
20
@@ -44,7 +44,7 @@ def run(host: str, port: int, reload: bool, workers: int | None) -> None:
44
44
)
45
45
46
46
47
- def install_plugin (path : str , repo_url : str ) -> None :
47
+ async def install_plugin (path : str , repo_url : str ) -> None :
48
48
if not path and not repo_url :
49
49
raise cappa .Exit ('path 或 repo_url 必须指定其中一项' , code = 1 )
50
50
if path and repo_url :
@@ -55,9 +55,9 @@ def install_plugin(path: str, repo_url: str) -> None:
55
55
56
56
try :
57
57
if path :
58
- plugin_name = run_await ( install_zip_plugin ) (file = path )
58
+ plugin_name = await install_zip_plugin (file = path )
59
59
if repo_url :
60
- plugin_name = run_await ( install_git_plugin ) (repo_url = repo_url )
60
+ plugin_name = await install_git_plugin (repo_url = repo_url )
61
61
except Exception as e :
62
62
raise cappa .Exit (e .msg if isinstance (e , BaseExceptionMixin ) else str (e ), code = 1 )
63
63
@@ -105,8 +105,8 @@ class Add:
105
105
cappa .Arg (long = True , help = 'Git 插件的仓库地址' ),
106
106
]
107
107
108
- def __call__ (self ):
109
- install_plugin (path = self .path , repo_url = self .repo_url )
108
+ async def __call__ (self ):
109
+ await install_plugin (path = self .path , repo_url = self .repo_url )
110
110
111
111
112
112
@dataclass
@@ -124,4 +124,4 @@ def __call__(self):
124
124
125
125
def main () -> None :
126
126
output = cappa .Output (error_format = '[red]Error[/]: {message}\n \n 更多信息,尝试 "[cyan]--help[/]"' )
127
- cappa .invoke (FbaCli , output = output )
127
+ asyncio . run ( cappa .invoke_async (FbaCli , output = output ) )
0 commit comments