replbase 0.0.2__tar.gz → 0.0.3__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.2 → replbase-0.0.3}/PKG-INFO +1 -1
- {replbase-0.0.2 → replbase-0.0.3}/pyproject.toml +1 -1
- {replbase-0.0.2 → replbase-0.0.3}/replbase/repl_base.py +16 -1
- {replbase-0.0.2 → replbase-0.0.3}/LICENSE +0 -0
- {replbase-0.0.2 → replbase-0.0.3}/README.md +0 -0
- {replbase-0.0.2 → replbase-0.0.3}/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.3"
|
|
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"
|
|
@@ -46,6 +46,8 @@ class ReplCommand:
|
|
|
46
46
|
command: Callable = None
|
|
47
47
|
help_txt: str = ""
|
|
48
48
|
parser: argparse.ArgumentParser = None
|
|
49
|
+
def_args: list = None
|
|
50
|
+
def_kwargs: dict = None
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
@dataclass
|
|
@@ -194,6 +196,8 @@ class ReplBase:
|
|
|
194
196
|
help_txt: str = "",
|
|
195
197
|
use_parser: bool = False,
|
|
196
198
|
description: str = "",
|
|
199
|
+
*def_args,
|
|
200
|
+
**def_kwargs,
|
|
197
201
|
) -> ReplCommand:
|
|
198
202
|
"""Add a command to the REPL
|
|
199
203
|
|
|
@@ -207,6 +211,8 @@ class ReplBase:
|
|
|
207
211
|
to the new ReplCommand instance. Defaults to False.
|
|
208
212
|
description (str, optional): Optional description for the
|
|
209
213
|
ArgumentParser help text. Defaults to help_txt.
|
|
214
|
+
def_args: Default arguments for the command function
|
|
215
|
+
def_kwargs: Default keyword arguments for the command function
|
|
210
216
|
|
|
211
217
|
Returns:
|
|
212
218
|
ReplCommand: The new ReplCommand instance
|
|
@@ -217,6 +223,11 @@ class ReplBase:
|
|
|
217
223
|
new_cmd.parser = argparse.ArgumentParser(
|
|
218
224
|
description=description or help_txt
|
|
219
225
|
)
|
|
226
|
+
if def_args:
|
|
227
|
+
new_cmd.def_args = def_args
|
|
228
|
+
if def_kwargs:
|
|
229
|
+
new_cmd.def_kwargs = def_kwargs
|
|
230
|
+
|
|
220
231
|
self.commands[cmd_name] = new_cmd
|
|
221
232
|
return new_cmd
|
|
222
233
|
|
|
@@ -292,7 +303,11 @@ class ReplBase:
|
|
|
292
303
|
|
|
293
304
|
cmd.command(cmd.parser.parse_args(cmd_args))
|
|
294
305
|
else:
|
|
295
|
-
cmd.
|
|
306
|
+
cmd_args = cmd_args or cmd.def_args
|
|
307
|
+
if cmd.def_kwargs:
|
|
308
|
+
cmd.command(*cmd_args, **cmd.def_kwargs)
|
|
309
|
+
else:
|
|
310
|
+
cmd.command(*cmd_args)
|
|
296
311
|
else:
|
|
297
312
|
self.print(
|
|
298
313
|
"[bold yellow][WARNING]: No function provided for command[/bold yellow]"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|