replbase 0.0.65__tar.gz → 0.0.66__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.65
3
+ Version: 0.0.66
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.65"
7
+ version = "0.0.66"
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"
@@ -115,6 +115,9 @@ class CommandMeta:
115
115
  flag_names: dict[str, list[str]] = field(default_factory=dict)
116
116
  """ Flag names to use for the ReplCommand.parser arguments embedded in the docstring """
117
117
 
118
+ used_flags: set[str] = field(default_factory=set)
119
+ """ Reference to keep track of unique flag names """
120
+
118
121
  def __post_init__(self) -> None:
119
122
 
120
123
  if not self.func:
@@ -253,7 +256,7 @@ class CommandMeta:
253
256
  try:
254
257
  arg_type = self.type_hints.get(arg, str)
255
258
 
256
- flag_name = self.flag_names.get(arg)
259
+ flag_names = [self.flag_names.get(arg)]
257
260
 
258
261
  cmd_init = {"help": self.args.get(arg)}
259
262
 
@@ -278,10 +281,10 @@ class CommandMeta:
278
281
  cmd_init["default"] = parm.default
279
282
 
280
283
  if cmd_init:
281
- repl_cmd.parser.add_argument(flag_name, **cmd_init)
284
+ repl_cmd.parser.add_argument(flag_names, **cmd_init)
282
285
 
283
286
  else:
284
- repl_cmd.parser.add_argument(flag_name)
287
+ repl_cmd.parser.add_argument(flag_names)
285
288
  except TypeError as e:
286
289
  print(
287
290
  f"[ERROR]: {e} for:\n{self.func.__name__}.{arg} with {arg_type} and {parm.default}"
@@ -318,7 +321,14 @@ class CommandMeta:
318
321
  if self.is_arg_optional(arg):
319
322
  flag = "--" + flag.replace("_", "-")
320
323
 
321
- self.flag_names[arg] = flag
324
+ self.flag_names[arg] = [flag]
325
+ char = flag[0]
326
+ if not char.lower() in self.used_flags:
327
+ self.flag_names[arg].append(f"-{char.lower()}")
328
+ self.used_flags.add(char.lower())
329
+ elif char.upper() in self.used_flags:
330
+ self.flag_names[arg].append(f"-{char.upper()}")
331
+ self.used_flags.add(char.upper())
322
332
 
323
333
  def parse_lines(self) -> None:
324
334
  """Parse the lines of the docstring into the appropriate sections"""
File without changes
File without changes