@@ -218,17 +218,17 @@ def cmd_wrapper(*args: Any, **kwargs: Any) -> bool | None:
218
218
219
219
220
220
def with_argparser (
221
- parser : argparse .ArgumentParser
222
- | Callable [[], argparse .ArgumentParser ]
223
- | Callable [[CommandParentType ], argparse .ArgumentParser ],
221
+ parser : argparse .ArgumentParser # existing parser
222
+ | Callable [[], argparse .ArgumentParser ] # function or staticmethod
223
+ | Callable [[CommandParentType ], argparse .ArgumentParser ], # Cmd or CommandSet classmethod
224
224
* ,
225
225
ns_provider : Callable [..., argparse .Namespace ] | None = None ,
226
226
preserve_quotes : bool = False ,
227
227
with_unknown_args : bool = False ,
228
228
) -> Callable [[ArgparseCommandFunc [CommandParent ]], RawCommandFuncOptionalBoolReturn [CommandParent ]]:
229
229
"""Decorate a ``do_*`` method to populate its ``args`` argument with the given instance of argparse.ArgumentParser.
230
230
231
- :param parser: unique instance of ArgumentParser or a callable that returns an ArgumentParser
231
+ :param parser: instance of ArgumentParser or a callable that returns an ArgumentParser for this command
232
232
:param ns_provider: An optional function that accepts a cmd2.Cmd or cmd2.CommandSet object as an argument and returns an
233
233
argparse.Namespace. This is useful if the Namespace needs to be prepopulated with state data that
234
234
affects parsing.
@@ -352,9 +352,9 @@ def cmd_wrapper(*args: Any, **kwargs: dict[str, Any]) -> bool | None:
352
352
def as_subcommand_to (
353
353
command : str ,
354
354
subcommand : str ,
355
- parser : argparse .ArgumentParser
356
- | Callable [[], argparse .ArgumentParser ]
357
- | Callable [[CommandParentType ], argparse .ArgumentParser ],
355
+ parser : argparse .ArgumentParser # existing parser
356
+ | Callable [[], argparse .ArgumentParser ] # function or staticmethod
357
+ | Callable [[CommandParentType ], argparse .ArgumentParser ], # Cmd or CommandSet classmethod
358
358
* ,
359
359
help : str | None = None , # noqa: A002
360
360
aliases : list [str ] | None = None ,
@@ -363,7 +363,7 @@ def as_subcommand_to(
363
363
364
364
:param command: Command Name. Space-delimited subcommands may optionally be specified
365
365
:param subcommand: Subcommand name
366
- :param parser: argparse Parser for this subcommand
366
+ :param parser: instance of ArgumentParser or a callable that returns an ArgumentParser for this subcommand
367
367
:param help: Help message for this subcommand which displays in the list of subcommands of the command we are adding to.
368
368
This is passed as the help argument to subparsers.add_parser().
369
369
:param aliases: Alternative names for this subcommand. This is passed as the alias argument to
0 commit comments