Skip to content

Commit e62921c

Browse files
authored
v2.3.1: 优化命令行和JmOption的配置方式,简化使用 (#139)
1 parent 89deeda commit e62921c

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

assets/docs/教程:使用GitHub Actions下载禁漫本子.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262

6363
如果你发现GitHub Actions显示❌,表明出现了问题,运行失败。
6464

65-
6665
下面是问题的排查步骤:
6766

6867
1. 检查你在步骤2中填写是否有误。

release.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
def add_output(k, v):
7-
print(f'set {k} = {v}')
8-
print(os.system(f'echo {k}={v} >> $GITHUB_OUTPUT'))
7+
cmd = f'echo {k}="{v}" >> $GITHUB_OUTPUT'
8+
print(cmd, os.system(cmd))
99

1010

1111
msg = sys.argv[1]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
],
4848
entry_points={
4949
'console_scripts': [
50-
'jmcomic = jmcomic:main'
50+
'jmcomic = jmcomic.cl:main'
5151
]
5252
}
5353
)

src/jmcomic/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# 被依赖方 <--- 使用方
33
# config <--- entity <--- toolkit <--- client <--- option <--- downloader
44

5-
__version__ = '2.3.0'
5+
__version__ = '2.3.1'
66

77
from .api import *
88
from .jm_plugin import *
9-
from .cl import main

src/jmcomic/cl.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ def parse_arg(self):
4242
parser.add_argument(
4343
'--option',
4444
help='path to the option file, you can also specify it by env `JM_OPTION_PATH`',
45+
type=str,
4546
default=get_env('JM_OPTION_PATH', ''),
4647
)
4748

4849
args = parser.parse_args()
49-
if len(args.option) != 0:
50-
self.option_path = os.path.abspath(args.option)
51-
else:
50+
option = args.option
51+
if len(option) == 0 or option == "''":
5252
self.option_path = None
53+
else:
54+
self.option_path = os.path.abspath(option)
5355

5456
self.raw_id_list = args.id_list
5557
self.parse_raw_id()

src/jmcomic/jm_option.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,29 @@ def decide_image_filepath(self, image: JmImageDetail) -> str:
218218
下面是创建对象相关方法
219219
"""
220220

221+
@classmethod
222+
def default_dict(cls) -> Dict:
223+
return JmModuleConfig.option_default_dict()
224+
225+
@classmethod
226+
def default(cls, proxies=None, domain=None) -> 'JmOption':
227+
"""
228+
使用默认的 JmOption
229+
proxies, domain 为常用配置项,为了方便起见直接支持参数配置。
230+
其他配置项建议还是使用配置文件
231+
@param proxies: clash; 127.0.0.1:7890; v2ray
232+
@param domain: 18comic.vip; ["18comic.vip"]
233+
"""
234+
if proxies is not None or domain is not None:
235+
return cls.construct({
236+
'client': {
237+
'domain': [domain] if isinstance(domain, str) else domain,
238+
'postman': {'meta_data': {'proxies': ProxyBuilder.build_by_str(proxies)}},
239+
},
240+
})
241+
242+
return cls.construct({})
243+
221244
@classmethod
222245
def construct(cls, dic: Dict, cover_default=True) -> 'JmOption':
223246
if cover_default:
@@ -286,7 +309,10 @@ def new_jm_client(self, domain_list=None, impl=None, **kwargs) -> JmcomicClient:
286309
postman = Postmans.create(data=postman_conf)
287310

288311
# domain_list
289-
domain_list: List[str] = domain_list or self.client.domain
312+
if domain_list is None:
313+
domain_list = self.client.domain
314+
315+
domain_list: List[str]
290316
if len(domain_list) == 0:
291317
domain_list = [JmModuleConfig.domain()]
292318

@@ -303,14 +329,6 @@ def new_jm_client(self, domain_list=None, impl=None, **kwargs) -> JmcomicClient:
303329

304330
return client
305331

306-
@classmethod
307-
def default_dict(cls) -> Dict:
308-
return JmModuleConfig.option_default_dict()
309-
310-
@classmethod
311-
def default(cls):
312-
return cls.construct({})
313-
314332
@classmethod
315333
def merge_default_dict(cls, user_dict, default_dict=None):
316334
"""

0 commit comments

Comments
 (0)