summaryrefslogtreecommitdiff
path: root/src/mailman/bin/mailman.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-08-16 09:32:10 -0400
committerBarry Warsaw2009-08-16 09:32:10 -0400
commit82affb2668ec6fa2d04fe7965a4c317eb13d8fce (patch)
treefea7c42631eda905798fedc167ff0dfe35862df3 /src/mailman/bin/mailman.py
parent592f3d56d2fd87cf06fdeb2bb63907a82ec172b2 (diff)
downloadmailman-82affb2668ec6fa2d04fe7965a4c317eb13d8fce.tar.gz
mailman-82affb2668ec6fa2d04fe7965a4c317eb13d8fce.tar.zst
mailman-82affb2668ec6fa2d04fe7965a4c317eb13d8fce.zip
Diffstat (limited to 'src/mailman/bin/mailman.py')
-rw-r--r--src/mailman/bin/mailman.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mailman/bin/mailman.py b/src/mailman/bin/mailman.py
index 7ff8310a8..c1b2931a4 100644
--- a/src/mailman/bin/mailman.py
+++ b/src/mailman/bin/mailman.py
@@ -60,10 +60,26 @@ def main():
# partially parse the arguments now, then initialize the system, then find
# the plugins. Punt on this for now.
subparser = parser.add_subparsers(title='Commands')
+ subcommands = []
for command_class in find_components('mailman.commands', ICLISubCommand):
command = command_class()
verifyObject(ICLISubCommand, command)
- command.add(parser, subparser)
+ subcommands.append(command)
+ # --help should display the subcommands by alphabetical order, except that
+ # 'mailman help' should be first.
+ def sort_function(command, other):
+ if command.name == 'help':
+ return -1
+ elif other.name == 'help':
+ return 1
+ else:
+ return cmp(command.name, other.name)
+ subcommands.sort(cmp=sort_function)
+ for command in subcommands:
+ command_parser = subparser.add_parser(
+ command.name, help=_(command.__doc__))
+ command.add(parser, command_parser)
+ command_parser.set_defaults(func=command.process)
args = parser.parse_args()
if len(args.__dict__) == 0:
# No arguments or subcommands were given.