replbase 0.0.14__tar.gz → 0.0.16__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: replbase
3
- Version: 0.0.14
3
+ Version: 0.0.16
4
4
  Summary: "Combination of other REPL tools into a reusable class that generates a REPL"
5
5
  License: MIT
6
6
  Author: Joseph Bochinski
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "replbase"
7
- version = "0.0.14"
7
+ version = "0.0.16"
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"
@@ -20,7 +20,7 @@ import re
20
20
  import shlex
21
21
 
22
22
  from dataclasses import dataclass, field
23
- from typing import Callable, Literal
23
+ from typing import Any, Callable, Literal
24
24
 
25
25
  from prompt_toolkit import PromptSession
26
26
  from prompt_toolkit.history import FileHistory
@@ -222,6 +222,26 @@ class ReplBase:
222
222
  if choice and choice > 0 and choice <= len(choices):
223
223
  return choices[choice - 1]
224
224
 
225
+ def input_choice_dict(self, prompt: str, choices: dict) -> Any:
226
+ """Similar to input_choice, but with more control over the options
227
+
228
+ Args:
229
+ prompt (str): String to print to the user
230
+ choices (dict): Dict of choices; keys will be the displayed options, values will be the associated return value
231
+
232
+ Returns:
233
+ Any: Selected value
234
+ """
235
+
236
+ keys = list(choices.keys())
237
+ for idx, choice in enumerate(keys):
238
+ self.print(f"[{idx+1}]: {choice}")
239
+
240
+ choice = self.input_int(prompt)
241
+ if choice and choice > 0 and choice <= len(keys):
242
+ key = keys[choice]
243
+ return choices[key]
244
+
225
245
  def debug(self, *args) -> None:
226
246
  """Print only if debug_enabled == True"""
227
247
  if self.debug_enabled:
@@ -360,6 +380,9 @@ class ReplBase:
360
380
  )
361
381
  break
362
382
 
383
+ if self.parent:
384
+ self.parent.print_prompt()
385
+
363
386
 
364
387
  # endregion Classes
365
388
 
File without changes
File without changes