replbase 0.0.42__tar.gz → 0.0.44__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.42
3
+ Version: 0.0.44
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.42"
7
+ version = "0.0.44"
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"
@@ -119,6 +119,10 @@ class CommandMeta:
119
119
  else:
120
120
  self.additional_lines.append(part)
121
121
 
122
+ for arg, param in self.sig_parms.items():
123
+ if arg not in self.args:
124
+ self.args[arg] = [self.get_param_str(param)]
125
+
122
126
  self.parse_lines()
123
127
  self.parse_flags()
124
128
 
@@ -310,9 +314,5 @@ class CommandMeta:
310
314
  elif cur_arg:
311
315
  args[cur_arg].append(line)
312
316
 
313
- for arg, param in self.sig_parms.items():
314
- if arg not in args:
315
- args[arg].append(self.get_param_str(param))
316
-
317
317
  arg_strs = {arg: "\n".join(lines) for arg, lines in args.items()}
318
318
  self.args.update(arg_strs)
@@ -26,6 +26,7 @@ import stat
26
26
  import time
27
27
 
28
28
  from dataclasses import dataclass, field
29
+ from enum import Enum, EnumType
29
30
  from typing import Any, Callable, Literal, get_type_hints
30
31
 
31
32
  from prompt_toolkit import PromptSession
@@ -370,6 +371,25 @@ class ReplBase:
370
371
  key = keys[choice - 1]
371
372
  return choices[key]
372
373
 
374
+ def get_enum_val(self, prompt: str, enum_cls: EnumType) -> Enum:
375
+ """Prompt the user to select an enum value
376
+
377
+ Args:
378
+ prompt (str): Prompt to display
379
+ enum_cls (EnumType): Enum class to select from
380
+
381
+ Returns:
382
+ Enum: Selected enum value
383
+ """
384
+
385
+ if enum_cls:
386
+ options = dict(enum_cls.__members__)
387
+
388
+ if len(options) == 1:
389
+ return list(options.values())[0]
390
+ else:
391
+ return self.input_choice_dict(prompt, options)
392
+
373
393
  def debug(self, *args) -> None:
374
394
  """Print only if debug_enabled == True"""
375
395
  if self.debug_enabled:
File without changes
File without changes