docs: Add command API to docs and extension dev page.

This commit is contained in:
Thomas Adamcik 2013-11-16 03:04:48 +01:00
parent 03c301705d
commit 0ab772f251
3 changed files with 42 additions and 0 deletions

9
docs/api/commands.rst Normal file
View File

@ -0,0 +1,9 @@
.. _commands-api:
************
Commands API
************
.. automodule:: mopidy.commands
:synopsis: Commands API for Mopidy CLI.
:members:

View File

@ -13,6 +13,7 @@ API reference
core
audio
frontends
commands
ext
config
http

View File

@ -305,6 +305,10 @@ This is ``mopidy_soundspot/__init__.py``::
from .backend import SoundspotBackend
return [SoundspotBackend]
def get_command(self):
from .commands import SoundspotCommand
return SoundspotCommand()
def register_gstreamer_elements(self):
from .mixer import SoundspotMixer
gobject.type_register(SoundspotMixer)
@ -374,6 +378,34 @@ details.
# Your backend implementation
Example command
===============
If you want to extend the Mopidy with a new helper not run from the server,
such as scanning for media, adding a command is the way to go. Your top level
command name will always match your extension name, but you are free to add
sub-commands with names of your choosing.
The skeleton of a commands would look like this. See :ref:`command-api` for more
details.
::
from mopidy import commands
class SoundspotCommand(commands.Command):
help = 'Some text that will show up in --help'
def __init__(self):
super(SoundspotCommand, self).__init__()
self.add_argument('--foo')
def run(self, args, config, extensions):
# Your backend implementation
return 0
Example GStreamer element
=========================