summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/plugin.py
blob: 75a3ff9f3177f5dc5e4040b916cbbef3dfd18457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Interface for creating a resmoke plugin."""

import abc


class Subcommand(object):
    """A resmoke subcommand to execute."""

    def execute(self):
        """Execute the subcommand."""
        raise NotImplementedError("execute must be implemented by Subcommand subclasses")


class PluginInterface(abc.ABC):
    """Subcommand/plugin interface."""

    def add_subcommand(self, subparsers):
        """
        Add parser options for this plugin.

        :param subparsers: argparse subparsers
        """
        raise NotImplementedError()

    def parse(self, subcommand, parser, parsed_args, **kwargs):
        """
        Resolve command-line options to a Subcommand or None.

        :param subcommand: equivalent to parsed_args.command
        :param parser: parser used
        :param parsed_args: output of parsing
        :param kwargs: additional args
        :return: None or a Subcommand
        """
        raise NotImplementedError()