@@ -218,17 +218,17 @@ def cmd_wrapper(*args: Any, **kwargs: Any) -> bool | None:
218218
219219
220220def 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
224224 * ,
225225 ns_provider : Callable [..., argparse .Namespace ] | None = None ,
226226 preserve_quotes : bool = False ,
227227 with_unknown_args : bool = False ,
228228) -> Callable [[ArgparseCommandFunc [CommandParent ]], RawCommandFuncOptionalBoolReturn [CommandParent ]]:
229229 """Decorate a ``do_*`` method to populate its ``args`` argument with the given instance of argparse.ArgumentParser.
230230
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
232232 :param ns_provider: An optional function that accepts a cmd2.Cmd or cmd2.CommandSet object as an argument and returns an
233233 argparse.Namespace. This is useful if the Namespace needs to be prepopulated with state data that
234234 affects parsing.
@@ -352,9 +352,9 @@ def cmd_wrapper(*args: Any, **kwargs: dict[str, Any]) -> bool | None:
352352def as_subcommand_to (
353353 command : str ,
354354 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
358358 * ,
359359 help : str | None = None , # noqa: A002
360360 aliases : list [str ] | None = None ,
@@ -363,7 +363,7 @@ def as_subcommand_to(
363363
364364 :param command: Command Name. Space-delimited subcommands may optionally be specified
365365 :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
367367 :param help: Help message for this subcommand which displays in the list of subcommands of the command we are adding to.
368368 This is passed as the help argument to subparsers.add_parser().
369369 :param aliases: Alternative names for this subcommand. This is passed as the alias argument to
0 commit comments