|
@@ -13,30 +13,18 @@ import shlex
|
|
|
import dotenv
|
|
|
from collections import OrderedDict
|
|
|
from .utils.str_util import preferredencoding
|
|
|
-
|
|
|
+from crawl_yuque.utils.frozen_dir import get_app_path
|
|
|
|
|
|
def parser_args(overrideArguments=None):
|
|
|
"""解析参数"""
|
|
|
|
|
|
argparser = argparse.ArgumentParser()
|
|
|
- argparser.add_argument('-c', '--config', help='config file', default='config.ini')
|
|
|
argparser.add_argument(
|
|
|
'command',
|
|
|
help='command: ',
|
|
|
- choices=['create', 'clone', 'push', 'delete', 'pull'],
|
|
|
- )
|
|
|
- argparser.add_argument('-d', '--debug', help='debug mode', action='store_true')
|
|
|
- argparser.add_argument(
|
|
|
- '-p',
|
|
|
- '--platform',
|
|
|
- help='set a platform',
|
|
|
- choices=['github', 'gitee', 'gitlab', 'gogs', 'gitea', 'bitbucket', 'coding'],
|
|
|
- default='github',
|
|
|
+ choices=['markdown', 'pdf', 'serve', 'version', 'help'],
|
|
|
)
|
|
|
- argparser.add_argument('-token', '--token', help='set a token')
|
|
|
- argparser.add_argument(
|
|
|
- '-repo_path', '--repo_path', help='set a repo'
|
|
|
- ) # , default=os.getcwd())
|
|
|
+ argparser.add_argument('-url', '--url', help='please input a url', type=str)
|
|
|
args = argparser.parse_args()
|
|
|
|
|
|
# remove None
|
|
@@ -52,8 +40,10 @@ def parser_args(overrideArguments=None):
|
|
|
|
|
|
system_conf.update(user_conf)
|
|
|
system_conf.update(command_line_conf)
|
|
|
- if args.command == None and args.extractor == None:
|
|
|
- raise 'Error, please input cmd and extractor params11'
|
|
|
+ app_path = get_app_path()
|
|
|
+ system_conf["app_path"] = app_path
|
|
|
+ # if args.command == None and args.extractor == None:
|
|
|
+ # raise 'Error, please input cmd and extractor params11'
|
|
|
return system_conf
|
|
|
|
|
|
|
|
@@ -67,7 +57,7 @@ def _read_custom_conf(config_path: str) -> OrderedDict:
|
|
|
|
|
|
try:
|
|
|
with open(config_path, 'r', encoding=preferredencoding()) as f:
|
|
|
- contents = f.read()
|
|
|
+ contents: str = f.read()
|
|
|
res = compat_shlex_split(contents, comments=True)
|
|
|
except Exception as e:
|
|
|
return []
|
|
@@ -77,7 +67,7 @@ def _read_custom_conf(config_path: str) -> OrderedDict:
|
|
|
def _read_user_conf() -> OrderedDict:
|
|
|
"""读取用户配置文件: .env 文件"""
|
|
|
user_conf = OrderedDict()
|
|
|
- dotenv_path = '.env'
|
|
|
+ dotenv_path = os.path.join(get_app_path(), '.env')
|
|
|
if os.path.exists(dotenv_path):
|
|
|
user_conf = dotenv.dotenv_values(dotenv_path)
|
|
|
return OrderedDict(user_conf)
|