diff options
| -rw-r--r-- | src/mailman/bin/mailman.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_help.py | 48 | ||||
| -rw-r--r-- | src/mailman/commands/cli_lists.py | 2 | ||||
| -rw-r--r-- | src/mailman/interfaces/command.py | 4 |
4 files changed, 53 insertions, 3 deletions
diff --git a/src/mailman/bin/mailman.py b/src/mailman/bin/mailman.py index 42b145e67..7ff8310a8 100644 --- a/src/mailman/bin/mailman.py +++ b/src/mailman/bin/mailman.py @@ -63,7 +63,7 @@ def main(): for command_class in find_components('mailman.commands', ICLISubCommand): command = command_class() verifyObject(ICLISubCommand, command) - command.add(subparser) + command.add(parser, subparser) args = parser.parse_args() if len(args.__dict__) == 0: # No arguments or subcommands were given. diff --git a/src/mailman/commands/cli_help.py b/src/mailman/commands/cli_help.py new file mode 100644 index 000000000..4cffaaf87 --- /dev/null +++ b/src/mailman/commands/cli_help.py @@ -0,0 +1,48 @@ +# Copyright (C) 2009 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see <http://www.gnu.org/licenses/>. + +"""The 'help' subcommand.""" + +from __future__ import absolute_import, unicode_literals + +__metaclass__ = type +__all__ = [ + 'Help', + ] + + +from zope.interface import implements + +from mailman.interfaces.command import ICLISubCommand + + + +class Help: + """The `help` subcommand.""" + + implements(ICLISubCommand) + + def add(self, parser, subparser): + """See `ICLISubCommand`.""" + self.parser = parser + help_parser = subparser.add_parser( + 'help', help=('show this help message and exit')) + help_parser.set_defaults(func=self.process) + + def process(self, args): + """See `ICLISubCommand`.""" + self.parser.print_help() diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py index 6757099d9..0d61aa701 100644 --- a/src/mailman/commands/cli_lists.py +++ b/src/mailman/commands/cli_lists.py @@ -38,7 +38,7 @@ class Lists: implements(ICLISubCommand) - def add(self, subparser): + def add(self, parser, subparser): """See `ICLISubCommand`.""" lists_parser = subparser.add_parser( 'lists', help=_('List all mailing lists')) diff --git a/src/mailman/interfaces/command.py b/src/mailman/interfaces/command.py index 14e7f9dd6..074359707 100644 --- a/src/mailman/interfaces/command.py +++ b/src/mailman/interfaces/command.py @@ -73,9 +73,11 @@ class IEmailCommand(Interface): class ICLISubCommand(Interface): """A command line interface subcommand.""" - def add(subparser): + def add(parser, subparser): """Add the subcommand to the subparser. + :param parser: The argument parser. + :type parser: `argparse.ArgumentParser` :param subparser: The argument subparser. :type subparser: `argparse.ArgumentParser` """ |
