replbase 0.0.55__tar.gz → 0.0.57__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.55
3
+ Version: 0.0.57
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.55"
7
+ version = "0.0.57"
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"
@@ -175,9 +175,13 @@ class CommandMeta:
175
175
  if doc:
176
176
  return doc
177
177
 
178
- def gen_command(self) -> ReplCommand:
178
+ def gen_command(self, hyphenate: bool = True) -> ReplCommand:
179
179
  """Generate a ReplCommand object from the provided function
180
180
 
181
+ Args:
182
+ hyphenate (bool, optional): Use hyphens for flag names.
183
+ Defaults to True.
184
+
181
185
  Raises:
182
186
  ValueError: If no registry command is provided
183
187
 
@@ -191,8 +195,14 @@ class CommandMeta:
191
195
  help_text = self.summary
192
196
  full_help = self.summary + self.additional
193
197
 
198
+ cmd_name = (
199
+ self.func.__name__.replace("_", "-")
200
+ if hyphenate
201
+ else self.func.__name__
202
+ )
203
+
194
204
  repl_cmd = self.register_cmd(
195
- cmd_name=self.func.__name__,
205
+ cmd_name=cmd_name,
196
206
  cmd_func=self.func,
197
207
  help_txt=help_text,
198
208
  use_parser=True,
@@ -209,6 +209,8 @@ class ReplBase:
209
209
 
210
210
  session: PromptSession = None
211
211
 
212
+ cmd_defs: dict[str, CommandMeta] = field(default_factory=dict)
213
+
212
214
  def __post_init__(self) -> None:
213
215
  if isinstance(self.commands, dict):
214
216
  for cmd_name, cmd in self.commands.items():
@@ -471,10 +473,11 @@ class ReplBase:
471
473
  if not callable(cmd):
472
474
  return
473
475
 
474
- if hyphenate:
475
- cmd_name = cmd_name.replace("_", "-")
476
-
477
- return CommandMeta(func=cmd, register_cmd=self.add_command).gen_command()
476
+ cmd_meta = CommandMeta(func=cmd, register_cmd=self.add_command).gen_command(
477
+ hyphenate=hyphenate
478
+ )
479
+ self.cmd_defs[cmd_name] = cmd_meta
480
+ return cmd_meta
478
481
 
479
482
  def setup_cmds(self, *cmd_names: list[str]) -> None:
480
483
  """Automatically configure commands based on the provided names
File without changes
File without changes