replbase 0.0.64__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.64
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.64"
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
 
@@ -268,7 +271,6 @@ class CommandMeta:
268
271
  if isinstance(arg_type, GenericAlias):
269
272
  main_type, sub_type = extract_type_info(parm.annotation)
270
273
  if main_type is list:
271
- cmd_init["nargs"] = "+"
272
274
  cmd_init["action"] = "append"
273
275
  if sub_type in AUTO_ARG_TYPES:
274
276
  cmd_init["type"] = sub_type
@@ -279,10 +281,10 @@ class CommandMeta:
279
281
  cmd_init["default"] = parm.default
280
282
 
281
283
  if cmd_init:
282
- repl_cmd.parser.add_argument(flag_name, **cmd_init)
284
+ repl_cmd.parser.add_argument(flag_names, **cmd_init)
283
285
 
284
286
  else:
285
- repl_cmd.parser.add_argument(flag_name)
287
+ repl_cmd.parser.add_argument(flag_names)
286
288
  except TypeError as e:
287
289
  print(
288
290
  f"[ERROR]: {e} for:\n{self.func.__name__}.{arg} with {arg_type} and {parm.default}"
@@ -319,7 +321,14 @@ class CommandMeta:
319
321
  if self.is_arg_optional(arg):
320
322
  flag = "--" + flag.replace("_", "-")
321
323
 
322
- 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())
323
332
 
324
333
  def parse_lines(self) -> None:
325
334
  """Parse the lines of the docstring into the appropriate sections"""
File without changes
File without changes