replbase 0.0.54__tar.gz → 0.0.56__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.
- {replbase-0.0.54 → replbase-0.0.56}/PKG-INFO +1 -1
- {replbase-0.0.54 → replbase-0.0.56}/pyproject.toml +1 -1
- {replbase-0.0.54 → replbase-0.0.56}/replbase/cmd_meta.py +12 -2
- {replbase-0.0.54 → replbase-0.0.56}/replbase/repl_base.py +4 -2
- {replbase-0.0.54 → replbase-0.0.56}/LICENSE +0 -0
- {replbase-0.0.54 → replbase-0.0.56}/README.md +0 -0
- {replbase-0.0.54 → replbase-0.0.56}/replbase/__init__.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "replbase"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.56"
|
|
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=
|
|
205
|
+
cmd_name=cmd_name,
|
|
196
206
|
cmd_func=self.func,
|
|
197
207
|
help_txt=help_text,
|
|
198
208
|
use_parser=True,
|
|
@@ -462,7 +462,7 @@ class ReplBase:
|
|
|
462
462
|
self.commands[cmd_name] = new_cmd
|
|
463
463
|
return new_cmd
|
|
464
464
|
|
|
465
|
-
def gen_command(self, cmd_name: str) -> ReplCommand:
|
|
465
|
+
def gen_command(self, cmd_name: str, hyphenate: bool = True) -> ReplCommand:
|
|
466
466
|
if not hasattr(self, cmd_name):
|
|
467
467
|
return
|
|
468
468
|
|
|
@@ -471,7 +471,9 @@ class ReplBase:
|
|
|
471
471
|
if not callable(cmd):
|
|
472
472
|
return
|
|
473
473
|
|
|
474
|
-
return CommandMeta(func=cmd, register_cmd=self.add_command).gen_command(
|
|
474
|
+
return CommandMeta(func=cmd, register_cmd=self.add_command).gen_command(
|
|
475
|
+
hyphenate=hyphenate
|
|
476
|
+
)
|
|
475
477
|
|
|
476
478
|
def setup_cmds(self, *cmd_names: list[str]) -> None:
|
|
477
479
|
"""Automatically configure commands based on the provided names
|
|
File without changes
|
|
File without changes
|
|
File without changes
|