replbase 0.0.9__tar.gz → 0.0.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {replbase-0.0.9 → replbase-0.0.12}/PKG-INFO +1 -1
- {replbase-0.0.9 → replbase-0.0.12}/pyproject.toml +1 -1
- {replbase-0.0.9 → replbase-0.0.12}/replbase/repl_base.py +8 -5
- {replbase-0.0.9 → replbase-0.0.12}/LICENSE +0 -0
- {replbase-0.0.9 → replbase-0.0.12}/README.md +0 -0
- {replbase-0.0.9 → replbase-0.0.12}/replbase/__init__.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "replbase"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.12"
|
|
8
8
|
description = "\"Combination of other REPL tools into a reusable class that generates a REPL\""
|
|
9
9
|
authors = [ "Joseph Bochinski <stirgejr@gmail.com>",]
|
|
10
10
|
license = "MIT"
|
|
@@ -51,7 +51,6 @@ class ReplCommand:
|
|
|
51
51
|
command: Callable = None
|
|
52
52
|
help_txt: str = ""
|
|
53
53
|
parser: argparse.ArgumentParser = None
|
|
54
|
-
def_args: list = field(default_factory=list)
|
|
55
54
|
def_kwargs: dict = field(default_factory=dict)
|
|
56
55
|
|
|
57
56
|
|
|
@@ -212,6 +211,14 @@ class ReplBase:
|
|
|
212
211
|
return int(user_input)
|
|
213
212
|
return user_input
|
|
214
213
|
|
|
214
|
+
def input_choice(self, *args, choices: list[str]) -> str:
|
|
215
|
+
"""Prompt for a choice from a list of options"""
|
|
216
|
+
for idx, choice in enumerate(choices):
|
|
217
|
+
self.print(f"[{idx+1}]: {choice}")
|
|
218
|
+
choice = self.input_int(*args)
|
|
219
|
+
if choice and choice > 0 and choice <= len(choices):
|
|
220
|
+
return choices[choice - 1]
|
|
221
|
+
|
|
215
222
|
def debug(self, *args) -> None:
|
|
216
223
|
"""Print only if debug_enabled == True"""
|
|
217
224
|
if self.debug_enabled:
|
|
@@ -220,7 +227,6 @@ class ReplBase:
|
|
|
220
227
|
def add_command(
|
|
221
228
|
self,
|
|
222
229
|
cmd_name: str,
|
|
223
|
-
*def_args,
|
|
224
230
|
cmd_func: Callable = None,
|
|
225
231
|
help_txt: str = "",
|
|
226
232
|
use_parser: bool = False,
|
|
@@ -251,8 +257,6 @@ class ReplBase:
|
|
|
251
257
|
new_cmd.parser = argparse.ArgumentParser(
|
|
252
258
|
description=description or help_txt
|
|
253
259
|
)
|
|
254
|
-
if def_args:
|
|
255
|
-
new_cmd.def_args = def_args
|
|
256
260
|
if def_kwargs:
|
|
257
261
|
new_cmd.def_kwargs = def_kwargs
|
|
258
262
|
|
|
@@ -331,7 +335,6 @@ class ReplBase:
|
|
|
331
335
|
|
|
332
336
|
cmd.command(cmd.parser.parse_args(cmd_args))
|
|
333
337
|
else:
|
|
334
|
-
cmd_args = cmd_args or cmd.def_args
|
|
335
338
|
if cmd.def_kwargs:
|
|
336
339
|
cmd.command(*cmd_args, **cmd.def_kwargs)
|
|
337
340
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|