Barry Warsaw pushed to branch master at mailman / Mailman Core
Commits:
a5006222 by Abhilash Raj at 2017-08-09T20:45:54-07:00
Print the list of available commands with `mailman --help`
Overriding the format_options method of click.MultiCommand skips printing the
list of available commands. This commit just brings that option back so that
help text is now more informative.
- - - - -
f847e154 by Barry Warsaw at 2017-08-26T14:38:33-04:00
Add a test.
- - - - -
2 changed files:
- src/mailman/bin/mailman.py
- src/mailman/bin/tests/test_mailman.py
Changes:
=====================================
src/mailman/bin/mailman.py
=====================================
--- a/src/mailman/bin/mailman.py
+++ b/src/mailman/bin/mailman.py
@@ -81,6 +81,8 @@ class Subcommands(click.MultiCommand):
if opts:
with formatter.section('Options'):
formatter.write_dl(opts)
+ # Print the list of available commands.
+ super().format_commands(ctx, formatter)
@click.group(
=====================================
src/mailman/bin/tests/test_mailman.py
=====================================
--- a/src/mailman/bin/tests/test_mailman.py
+++ b/src/mailman/bin/tests/test_mailman.py
@@ -25,8 +25,10 @@ from mailman.app.lifecycle import create_list
from mailman.bin.mailman import main
from mailman.config import config
from mailman.database.transaction import transaction
+from mailman.interfaces.command import ICLISubCommand
from mailman.testing.layers import ConfigLayer
from mailman.utilities.datetime import now
+from mailman.utilities.modules import add_components
from unittest.mock import patch
@@ -45,6 +47,14 @@ class TestMailmanCommand(unittest.TestCase):
# works. It does actually show the correct program when run from the
# command line.
self.assertEqual(lines[0], 'Usage: main [OPTIONS] COMMAND [ARGS]...')
+ # The help output includes a list of subcommands, in sorted order.
+ commands = {}
+ add_components('mailman.commands', ICLISubCommand, commands)
+ help_commands = list(
+ line.split()[0].strip()
+ for line in lines[-len(commands):]
+ )
+ self.assertEqual(sorted(commands), help_commands)
def test_mailman_command_with_bad_subcommand_prints_help(self):
# Issue #137: Running `mailman` without a subcommand raises an
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/324226f1f859f6be5e932dc9abe638aba268d154...f847e15407bfbf824236547bdf728a1ae00bd405
---
View it on GitLab:
https://gitlab.com/mailman/mailman/compare/324226f1f859f6be5e932dc9abe638aba268d154...f847e15407bfbf824236547bdf728a1ae00bd405
You're receiving this email because of your account on gitlab.com.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org