# `mopidy.commands` — Commands API

class mopidy.commands.Command → None

  Command parser and runner for building trees of commands.

  This class provides a wraper around `argparse.ArgumentParser` for handling this type of command line application in a better way than argparse’s own sub-parser handling.

  add_argument(*args, **kwargs) → None

    Add an argument to the parser.

    This method takes all the same arguments as the `argparse.ArgumentParser` version of this method.

    Return type:

      `None`

  add_child(name, command) → None

    Add a child parser to consider using.

    Parameters:

      name (`str`) – name to use for the sub-command that is being added.

    Return type:

      `None`

  exit(status_code=0, message=None, usage=None) → NoReturn

    Optionally print a message and exit.

    Return type:

      `NoReturn`

  format_help(prog=None) → str

    Format help for current parser and children.

    Return type:

      `str`

  format_usage(prog=None) → str

    Format usage for current parser.

    Return type:

      `str`

  parse(args, prog=None) → Namespace

    Parse command line arguments.

    Will recursively parse commands until a final parser is found or an error occurs. In the case of errors we will print a message and exit. Otherwise, any overrides are applied and the current parser stored in the command attribute of the return value.

    Parameters:

      - args (`list`[`str`]) – list of arguments to parse

      - prog (`str` | `None`) – name to use for program

    Return type:

      `Namespace`

  run(args, config, *_args, **_kwargs) → int

    Run the command.

    Must be implemented by sub-classes that are not simply an intermediate in the command namespace.

    Return type:

      `int`

  set(**kwargs) → None

    Override a value in the finaly result of parsing.

    Return type:

      `None`

class mopidy.commands.ConfigCommand → None
  run(args, config, *_args, errors, schemas, **_kwargs) → int

    Run the command.

    Must be implemented by sub-classes that are not simply an intermediate in the command namespace.

class mopidy.commands.DepsCommand → None
  run(args, config, *_args, **_kwargs) → int

    Run the command.

    Must be implemented by sub-classes that are not simply an intermediate in the command namespace.

    Return type:

      `int`

class mopidy.commands.RootCommand → None
  run(args, config, *_args, **_kwargs) → int

    Run the command.

    Must be implemented by sub-classes that are not simply an intermediate in the command namespace.

    Return type:

      `int`