summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBarry Warsaw2009-08-09 11:25:59 -0400
committerBarry Warsaw2009-08-09 11:25:59 -0400
commit1dddebc50c9800688bcb9f7ba155a91cc5ed0fae (patch)
treeaf6c26bb0ba1fa10324cbc2e26e7ca72c2b0f082 /src
parentdf000679f72bfbf1d40e7d1553b376cda524be95 (diff)
downloadmailman-1dddebc50c9800688bcb9f7ba155a91cc5ed0fae.tar.gz
mailman-1dddebc50c9800688bcb9f7ba155a91cc5ed0fae.tar.zst
mailman-1dddebc50c9800688bcb9f7ba155a91cc5ed0fae.zip
Diffstat (limited to 'src')
-rw-r--r--src/mailman/bin/mailman.py2
-rw-r--r--src/mailman/commands/cli_help.py48
-rw-r--r--src/mailman/commands/cli_lists.py2
-rw-r--r--src/mailman/interfaces/command.py4
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`
"""