From 0ab772f251b7a1c0940071610d5f4b19c695afdb Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 16 Nov 2013 03:04:48 +0100 Subject: [PATCH] docs: Add command API to docs and extension dev page. --- docs/api/commands.rst | 9 +++++++++ docs/api/index.rst | 1 + docs/extensiondev.rst | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 docs/api/commands.rst diff --git a/docs/api/commands.rst b/docs/api/commands.rst new file mode 100644 index 00000000..f0469350 --- /dev/null +++ b/docs/api/commands.rst @@ -0,0 +1,9 @@ +.. _commands-api: + +************ +Commands API +************ + +.. automodule:: mopidy.commands + :synopsis: Commands API for Mopidy CLI. + :members: diff --git a/docs/api/index.rst b/docs/api/index.rst index bb29890b..f58552b7 100644 --- a/docs/api/index.rst +++ b/docs/api/index.rst @@ -13,6 +13,7 @@ API reference core audio frontends + commands ext config http diff --git a/docs/extensiondev.rst b/docs/extensiondev.rst index 05fe27c9..38fe1c55 100644 --- a/docs/extensiondev.rst +++ b/docs/extensiondev.rst @@ -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 =========================