summaryrefslogtreecommitdiff
path: root/src/mailman/bin/mailman.py
diff options
context:
space:
mode:
authorBarry Warsaw2016-03-24 09:55:18 -0400
committerBarry Warsaw2016-03-24 09:55:18 -0400
commitce9370a537683e6e4e934b8018d0fe3f2aa7f9ac (patch)
tree1c5ac62d66cfa75d6bf7abfb737ae401b49df2a8 /src/mailman/bin/mailman.py
parent8169b60bc3d5b771f3676ae12c65f6f92c67a76a (diff)
downloadmailman-ce9370a537683e6e4e934b8018d0fe3f2aa7f9ac.tar.gz
mailman-ce9370a537683e6e4e934b8018d0fe3f2aa7f9ac.tar.zst
mailman-ce9370a537683e6e4e934b8018d0fe3f2aa7f9ac.zip
Diffstat (limited to 'src/mailman/bin/mailman.py')
-rw-r--r--src/mailman/bin/mailman.py42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/mailman/bin/mailman.py b/src/mailman/bin/mailman.py
index f9163610b..7a443e9d6 100644
--- a/src/mailman/bin/mailman.py
+++ b/src/mailman/bin/mailman.py
@@ -17,15 +17,11 @@
"""The 'mailman' command dispatcher."""
-__all__ = [
- 'main',
- ]
-
-
import os
import argparse
from functools import cmp_to_key
+from mailman import public
from mailman.core.i18n import _
from mailman.core.initialize import initialize
from mailman.interfaces.command import ICLISubCommand
@@ -34,7 +30,24 @@ from mailman.version import MAILMAN_VERSION_FULL
from zope.interface.verify import verifyObject
-
+# --help should display the subcommands by alphabetical order, except that
+# 'mailman help' should be first.
+def _help_sorter(command, other):
+ """Sorting helper."""
+ if command.name == 'help':
+ return -1
+ elif other.name == 'help':
+ return 1
+ elif command.name < other.name:
+ return -1
+ elif command.name == other.name:
+ return 0
+ else:
+ assert command.name > other.name
+ return 1
+
+
+@public
def main():
"""The `mailman` command dispatcher."""
# Create the basic parser and add all globally common options.
@@ -66,22 +79,7 @@ def main():
command = command_class()
verifyObject(ICLISubCommand, command)
subcommands.append(command)
- # --help should display the subcommands by alphabetical order, except that
- # 'mailman help' should be first.
- def sort_function(command, other):
- """Sorting helper."""
- if command.name == 'help':
- return -1
- elif other.name == 'help':
- return 1
- elif command.name < other.name:
- return -1
- elif command.name == other.name:
- return 0
- else:
- assert command.name > other.name
- return 1
- subcommands.sort(key=cmp_to_key(sort_function))
+ subcommands.sort(key=cmp_to_key(_help_sorter))
for command in subcommands:
command_parser = subparser.add_parser(
command.name, help=_(command.__doc__))