Skip to content

Commit

Permalink
fix cli
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacharia2 committed Jun 16, 2024
1 parent 5fe7298 commit 1351fd2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 45 deletions.
56 changes: 28 additions & 28 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "supermemo-toolkit"
version = "0.1.4"
version = "0.1.5"
description = "SuperMemo 增强工具(CLI命令行)。包含图链整理、EPUB图书转换导入、Latex公式转图片等。"
license = "GPL-2.0-only"
authors = ["mingyue <[email protected]>"]
Expand Down Expand Up @@ -52,5 +52,5 @@ smtk = "supermemo_toolkit.smtk:main"
#设置poetry包管理工具的自定义pypi镜像源配置
[[tool.poetry.source]]
name = "tencent"
url = "http://mirrors.aliyun.com/pypi/simple/"
url = "https://mirrors.aliyun.com/pypi/simple/"
priority = "primary"
33 changes: 18 additions & 15 deletions supermemo_toolkit/smtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
from supermemo_toolkit.pathpix import im_sort_out, gui as im_sort_out_gui
from supermemo_toolkit.utilscripts import config as smtk_config

# 初始化操作
smtk_config_dir_path = smtk_config.get_config_dir()
smtk_config_file_path = os.path.join(smtk_config_dir_path, "conf.json")
init_conf_dict = {"program": "D:\\SuperMemo"}
curr_conf_dict = dict()
if not os.path.exists(smtk_config_dir_path):
os.makedirs(smtk_config_dir_path)
smtk_config.update_config(smtk_config_file_path, init_conf_dict)
elif os.path.exists(smtk_config_dir_path) and not os.path.exists(smtk_config_file_path):
smtk_config.update_config(smtk_config_file_path, init_conf_dict)
elif os.path.exists(smtk_config_file_path):
curr_conf_dict = smtk_config.read_config(smtk_config_file_path)
sm_location: dict = curr_conf_dict["program"]


@click.group()
@click.version_option()
Expand All @@ -19,6 +33,10 @@ def config():
"""Configuration commands"""


# 将config命令添加到main命令组中
main.add_command(config)


@config.command()
@click.argument('key')
@click.argument('value')
Expand Down Expand Up @@ -110,19 +128,4 @@ def pathpix(col_name, clean, fullpath, least_col, gui):


if __name__ == "__main__":
# 初始化操作
smtk_config_dir_path = smtk_config.get_config_dir()
smtk_config_file_path = os.path.join(smtk_config_dir_path, "conf.json")
init_conf_dict = {"program": "D:\\SuperMemo"}
curr_conf_dict = dict()
if not os.path.exists(smtk_config_dir_path):
os.makedirs(smtk_config_dir_path)
smtk_config.update_config(smtk_config_file_path, init_conf_dict)
elif os.path.exists(smtk_config_dir_path) and not os.path.exists(smtk_config_file_path):
smtk_config.update_config(smtk_config_file_path, init_conf_dict)
elif os.path.exists(smtk_config_file_path):
curr_conf_dict = smtk_config.read_config(smtk_config_file_path)
sm_location: dict = curr_conf_dict["program"]
# 将config命令添加到main命令组中
main.add_command(config)
main()

0 comments on commit 1351fd2

Please sign in to comment.