diff options
author | Eric Lin <anselor@gmail.com> | 2020-07-24 12:03:59 -0400 |
---|---|---|
committer | anselor <anselor@gmail.com> | 2020-08-04 13:38:08 -0400 |
commit | 787a31931ed4c4a18ae66a570d396b12b2b7b525 (patch) | |
tree | 89c103c71177ad8b0cac2e1355866c05a6c0c743 /cmd2 | |
parent | c05d2b0480f284a83dfe868b1aad3d780174c289 (diff) | |
download | cmd2-git-787a31931ed4c4a18ae66a570d396b12b2b7b525.tar.gz |
Updates the example to remove usage of the now remove ability to
register arbitrary functions as commands.
Added example that demonstrates use of each of the command decorators
with CommandSets.
Adds unit test that verifies that CommandSets containing decorators load
and process commands correctly.
Updated the constructor declaration for Cmd2ArgumentParser to explicitly
re-declare argparse constructor parameters.
Diffstat (limited to 'cmd2')
-rw-r--r-- | cmd2/argparse_custom.py | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/cmd2/argparse_custom.py b/cmd2/argparse_custom.py index 485f65c2..74bddfc7 100644 --- a/cmd2/argparse_custom.py +++ b/cmd2/argparse_custom.py @@ -728,11 +728,32 @@ class Cmd2HelpFormatter(argparse.RawTextHelpFormatter): class Cmd2ArgumentParser(argparse.ArgumentParser): """Custom ArgumentParser class that improves error and help output""" - def __init__(self, *args, **kwargs) -> None: - if 'formatter_class' not in kwargs: - kwargs['formatter_class'] = Cmd2HelpFormatter - - super().__init__(*args, **kwargs) + def __init__(self, + prog=None, + usage=None, + description=None, + epilog=None, + parents=None, + formatter_class=Cmd2HelpFormatter, + prefix_chars='-', + fromfile_prefix_chars=None, + argument_default=None, + conflict_handler='error', + add_help=True, + allow_abbrev=True) -> None: + super(Cmd2ArgumentParser, self).__init__( + prog=prog, + usage=usage, + description=description, + epilog=epilog, + parents=parents if parents else [], + formatter_class=formatter_class, + prefix_chars=prefix_chars, + fromfile_prefix_chars=fromfile_prefix_chars, + argument_default=argument_default, + conflict_handler=conflict_handler, + add_help=add_help, + allow_abbrev=allow_abbrev) def add_subparsers(self, **kwargs): """Custom override. Sets a default title if one was not given.""" |