|
1 | 1 | """Decorators for ``cmd2`` commands.""" |
2 | 2 |
|
3 | 3 | import argparse |
| 4 | +import functools |
4 | 5 | from collections.abc import ( |
5 | 6 | Callable, |
6 | 7 | Sequence, |
|
33 | 34 | def with_category( |
34 | 35 | category: str, |
35 | 36 | ) -> Callable[[UnboundCommandFunc[CmdOrSetT, P]], UnboundCommandFunc[CmdOrSetT, P]]: |
36 | | - """Decorate a ``do_*`` command method to apply a category. |
| 37 | + """Decorate a ``do_*`` command function to apply a category. |
37 | 38 |
|
38 | 39 | :param category: the name of the category in which this command should |
39 | 40 | be grouped when displaying the list of commands. |
@@ -159,7 +160,6 @@ def do_print_raw(self, arglist: list[str]): |
159 | 160 | ``` |
160 | 161 |
|
161 | 162 | """ |
162 | | - import functools |
163 | 163 |
|
164 | 164 | def arg_decorator(func: ArgListCommandFunc[CmdOrSetT]) -> RawCommandFunc[CmdOrSetT]: |
165 | 165 | """Decorate function that ingests an Argument List function and returns a raw command function. |
@@ -212,7 +212,7 @@ def with_argparser( |
212 | 212 | preserve_quotes: bool = False, |
213 | 213 | with_unknown_args: bool = False, |
214 | 214 | ) -> Callable[[ArgparseCommandFunc[CmdOrSetT]], RawCommandFunc[CmdOrSetT]]: |
215 | | - """Decorate a ``do_*`` method to populate its ``args`` argument with the given instance of Cmd2ArgumentParser. |
| 215 | + """Decorate a ``do_*`` command function to populate its ``args`` argument with a Cmd2ArgumentParser. |
216 | 216 |
|
217 | 217 | :param parser: instance of Cmd2ArgumentParser or a callable that returns a Cmd2ArgumentParser for this command |
218 | 218 | :param ns_provider: An optional function that accepts a cmd2.Cmd or cmd2.CommandSet object as an argument and returns an |
@@ -257,7 +257,6 @@ def do_argprint(self, args, unknown): |
257 | 257 | ``` |
258 | 258 |
|
259 | 259 | """ |
260 | | - import functools |
261 | 260 |
|
262 | 261 | def arg_decorator(func: ArgparseCommandFunc[CmdOrSetT]) -> RawCommandFunc[CmdOrSetT]: |
263 | 262 | """Decorate function that ingests an Argparse Command Function and returns a raw command function. |
@@ -343,7 +342,7 @@ def as_subcommand_to( |
343 | 342 | aliases: Sequence[str] | None = None, |
344 | 343 | **add_parser_kwargs: Any, |
345 | 344 | ) -> Callable[[ArgparseCommandFunc[CmdOrSetT]], ArgparseCommandFunc[CmdOrSetT]]: |
346 | | - """Tag this method as a subcommand to an existing argparse decorated command. |
| 345 | + """Tag this function as a subcommand to an existing argparse decorated command. |
347 | 346 |
|
348 | 347 | :param command: Command Name. Space-delimited subcommands may optionally be specified |
349 | 348 | :param subcommand: Subcommand name |
|
0 commit comments