diff --git a/mopidy/backends/base.py b/mopidy/backends/base.py index 6b980f06..9dc9befa 100644 --- a/mopidy/backends/base.py +++ b/mopidy/backends/base.py @@ -279,3 +279,34 @@ class BasePlaylistsProvider(object): *MUST be implemented by subclass.* """ raise NotImplementedError + + +class BaseSubCommandProvider(object): + """Sub-classes may optionally add arguments to the passed in parser. + + :param parser: parser you may add arguments to + :type parser: :class:`argparse.ArgumentParser` + """ + + name = None + """What the sub-command should be called. Will be run as ``mopidy NAME`` + + Example: ``scan`` + """ + + help = None + """Optional help text for the sub-command, will be displayed in help.""" + + def __init__(self, parser): + pass + + def run(self, args, config): + """Run the sub-command implemented by this provider. + + *MUST be implemented by subclass.* + + :param args: the argments object from argpase. + :param config: read only version of the mopidy config. + :returns: integer exit value for the process. + """ + raise NotImplementedError diff --git a/mopidy/ext.py b/mopidy/ext.py index c239c374..aa6b4cd0 100644 --- a/mopidy/ext.py +++ b/mopidy/ext.py @@ -87,6 +87,14 @@ class Extension(object): """ return [] + def get_sub_commands(self): + """List of sub-command classes + + :returns: list of + :class:`~mopidy.backends.base.BaseSubCommandProvider` subclasses + """ + return [] + def register_gstreamer_elements(self): """Hook for registering custom GStreamer elements