docs: Add command API to docs and extension dev page.
This commit is contained in:
parent
03c301705d
commit
0ab772f251
9
docs/api/commands.rst
Normal file
9
docs/api/commands.rst
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.. _commands-api:
|
||||||
|
|
||||||
|
************
|
||||||
|
Commands API
|
||||||
|
************
|
||||||
|
|
||||||
|
.. automodule:: mopidy.commands
|
||||||
|
:synopsis: Commands API for Mopidy CLI.
|
||||||
|
:members:
|
||||||
@ -13,6 +13,7 @@ API reference
|
|||||||
core
|
core
|
||||||
audio
|
audio
|
||||||
frontends
|
frontends
|
||||||
|
commands
|
||||||
ext
|
ext
|
||||||
config
|
config
|
||||||
http
|
http
|
||||||
|
|||||||
@ -305,6 +305,10 @@ This is ``mopidy_soundspot/__init__.py``::
|
|||||||
from .backend import SoundspotBackend
|
from .backend import SoundspotBackend
|
||||||
return [SoundspotBackend]
|
return [SoundspotBackend]
|
||||||
|
|
||||||
|
def get_command(self):
|
||||||
|
from .commands import SoundspotCommand
|
||||||
|
return SoundspotCommand()
|
||||||
|
|
||||||
def register_gstreamer_elements(self):
|
def register_gstreamer_elements(self):
|
||||||
from .mixer import SoundspotMixer
|
from .mixer import SoundspotMixer
|
||||||
gobject.type_register(SoundspotMixer)
|
gobject.type_register(SoundspotMixer)
|
||||||
@ -374,6 +378,34 @@ details.
|
|||||||
# Your backend implementation
|
# 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
|
Example GStreamer element
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user