From f00b94f18e1d82d1488cbcee6053f03423bc2f49 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sat, 22 Jul 2017 03:02:05 +0000 Subject: Convert to click for CLI options --- src/mailman/commands/cli_aliases.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/mailman/commands/cli_aliases.py') diff --git a/src/mailman/commands/cli_aliases.py b/src/mailman/commands/cli_aliases.py index 3ac46a1d9..4ce41eedd 100644 --- a/src/mailman/commands/cli_aliases.py +++ b/src/mailman/commands/cli_aliases.py @@ -17,30 +17,31 @@ """Generate Mailman alias files for your MTA.""" +import click + from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.utilities.modules import call_name +from mailman.utilities.options import I18nCommand from public import public from zope.interface import implementer +@click.command( + cls=I18nCommand, + help=_('Regenerate the aliases appropriate for your MTA.')) +@click.option( + '--directory', '-d', + type=click.Path(exists=True, file_okay=False, resolve_path=True, + writable=True), + help=_('An alternative directory to output the various MTA files to.')) +def aliases(directory): + call_name(config.mta.incoming).regenerate(directory) + + @public @implementer(ICLISubCommand) class Aliases: - """Regenerate the aliases appropriate for your MTA.""" - name = 'aliases' - - def add(self, parser, command_parser): - """See `ICLISubCommand`.""" - self.parser = parser - command_parser.add_argument( - '-d', '--directory', - action='store', help=_("""\ - An alternative directory to output the various MTA files to.""")) - - def process(self, args): - """See `ICLISubCommand`.""" - # Call the MTA-specific regeneration method. - call_name(config.mta.incoming).regenerate(args.directory) + command = aliases -- cgit v1.2.3-70-g09d2