1 # Copyright (C) 2008-2023 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <https://www.gnu.org/licenses/>.
18 """Interfaces defining email commands."""
21 from public
import public
22 from zope
.interface
import Attribute
, Interface
26 class ContinueProcessing(Enum
):
27 """Should `IEmailCommand.process()` continue or not."""
33 class IEmailResults(Interface
):
34 """The email command results object."""
36 output
= Attribute('An output file object for printing results to.')
40 class IEmailCommand(Interface
):
41 """An email command."""
43 name
= Attribute('Command name as seen in a -request email.')
45 argument_description
= Attribute('Description of command arguments.')
47 description
= Attribute('Command help.')
49 def process(mlist
, msg
, msgdata
, arguments
, results
):
50 """Process the email command.
52 :param mlist: The mailing list target of the command.
53 :param msg: The original message object.
54 :param msgdata: The message metadata.
55 :param arguments: The command arguments tuple.
56 :param results: An IEmailResults object for these commands.
57 :return: A `ContinueProcessing` enum specifying whether to continue
63 class ICLISubCommand(Interface
):
64 """A command line interface subcommand.
66 Subcommands are implemented using the `click` package. See
67 https://click.palletsprojects.com/en/7.x/ for details.
70 """The subcommand name as it will show up in `mailman --help`.
72 This must be unique; it is a runtime error if any plugin provides a
73 subcommand with a clashing name.
77 """The click command to run for this subcommand.
79 This must be a function decorated with at least the @click.command()
80 decorator. The function may also be decorated with other arguments as