v2.0.1
This commit is contained in:
10
clihelper.py
10
clihelper.py
@@ -14,7 +14,7 @@
|
||||
from __future__ import annotations
|
||||
from typing import Callable, TypedDict
|
||||
|
||||
version = (2, 0, 20231219)
|
||||
version = (2, 0, 1, 20231219)
|
||||
|
||||
|
||||
def request_input(prompt_msg: str,
|
||||
@@ -131,10 +131,14 @@ class _OptionNode(object):
|
||||
self.exec_func = exec_func if exec_func is not None else self._default_func
|
||||
self.args = args if args is not None else ()
|
||||
self.kwargs = kwargs if kwargs is not None else {}
|
||||
self.menu_config = menu_config if menu_config is not None else DEFAULT_MENU_CONFIG
|
||||
self.children = [] # type: list[_OptionNode]
|
||||
self._is_root = _is_root
|
||||
|
||||
self.menu_config = DEFAULT_MENU_CONFIG.copy()
|
||||
# 补充没有的设置
|
||||
if menu_config is not None:
|
||||
self.menu_config.update(menu_config)
|
||||
|
||||
@staticmethod
|
||||
def _default_func():
|
||||
"""用户没有指定执行函数时执行的默认函数"""
|
||||
@@ -307,4 +311,4 @@ class CliHelper(_OptionNode):
|
||||
super().__init__("Main Menu", menu_config=menu_config, _is_root=True)
|
||||
|
||||
if show_version:
|
||||
print(f"CliHelper v{version[0]}.{version[1]} ({version[-1]})\n")
|
||||
print(f"CliHelper v{version[0]}.{version[1]}.{version[2]} ({version[-1]})\n")
|
||||
|
||||
15
test.py
15
test.py
@@ -11,19 +11,8 @@ def new_folder(name):
|
||||
|
||||
|
||||
def test_helper():
|
||||
# c = CliHelper(right_padding=20, draw_menu_again=False)
|
||||
# n = c.add_option(title="New")
|
||||
# c.add_option(title="Open File", exec_func=open_file)
|
||||
# c.add_option(title="Save")
|
||||
# c.add_exit_option()
|
||||
#
|
||||
# c.add_return_option(n)
|
||||
# c.add_option(n, "New File")
|
||||
# c.add_option(n, "New Folder", new_folder, ("Temp",))
|
||||
# c.add_exit_option(n)
|
||||
#
|
||||
# c.start_loop()
|
||||
ch = CliHelper()
|
||||
ch = CliHelper({"right_padding": 20, "serial_marker": "->"})
|
||||
# ch = CliHelper()
|
||||
n = ch.add_option("New")
|
||||
n.add_return_option()
|
||||
n.add_option("New File")
|
||||
|
||||
Reference in New Issue
Block a user