replbase 0.0.8__tar.gz → 0.0.10__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.8 → replbase-0.0.10}/PKG-INFO +1 -1
- {replbase-0.0.8 → replbase-0.0.10}/pyproject.toml +1 -1
- {replbase-0.0.8 → replbase-0.0.10}/replbase/repl_base.py +16 -0
- {replbase-0.0.8 → replbase-0.0.10}/LICENSE +0 -0
- {replbase-0.0.8 → replbase-0.0.10}/README.md +0 -0
- {replbase-0.0.8 → replbase-0.0.10}/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.10"
|
|
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"
|
|
@@ -204,6 +204,22 @@ class ReplBase:
|
|
|
204
204
|
user_input = self.input(*args)
|
|
205
205
|
return user_input.strip().lower() in true_list
|
|
206
206
|
|
|
207
|
+
def input_prefer_int(self, *args) -> int | str:
|
|
208
|
+
"""Parse input as int if possible, otherwise return the string"""
|
|
209
|
+
|
|
210
|
+
user_input = self.input(*args).strip().split(".")[0].strip()
|
|
211
|
+
if is_num_str(user_input):
|
|
212
|
+
return int(user_input)
|
|
213
|
+
return user_input
|
|
214
|
+
|
|
215
|
+
def input_choice(self, *args, choices: list[str]) -> str:
|
|
216
|
+
"""Prompt for a choice from a list of options"""
|
|
217
|
+
for idx, choice in enumerate(choices):
|
|
218
|
+
self.print(f"[{idx+1}]: {choice}")
|
|
219
|
+
choice = self.input_int(*args)
|
|
220
|
+
if choice and choice > 0 and choice <= len(choices):
|
|
221
|
+
return choices[choice - 1]
|
|
222
|
+
|
|
207
223
|
def debug(self, *args) -> None:
|
|
208
224
|
"""Print only if debug_enabled == True"""
|
|
209
225
|
if self.debug_enabled:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|