Files changed (1)
-The ``Command`` class must define a ``run`` method. The first argument to your ``run`` , other than ``self``,
-is always ``app``: this is the Flask application instance that is passed directly to the ``Manager``; if you
-pass an app factory, the ``Manager`` will call this and pass the result to your ``Command``. Additional arguments
-Note that with ``@command`` and ``@option`` decorators, the function must take the Flask application instance as the first
Positional and optional arguments are stored as ``Option`` instances - see the :ref:`api` below for details.
If you are using the ``@command`` decorator, it's much easier - the options are extracted automatically from your function arguments. This is an example of a positional argument::
The short-form **-n** is formed from the first letter of the argument, so "name" > "-n". Therefore it's a good idea that your
-optional argument variable names begin with different letters (The first argument, "app", is ignored,
The second issue is that the **-h** switch always runs the help text for that command, so avoid arguments starting with the letter "h".
The ``@command`` decorator is fine for simple operations, but often you need the flexibility. For more sophisticated options it's better to use the ``@option`` decorator::
-The ``Shell`` command starts a Python shell. You can pass in a ``make_context`` argument, which must be a ``callable`` returning a ``dict``. As with commands, it always takes the ``app`` as the first argument. By default, this is just a dict returning the ``app`` instance::
+The ``Shell`` command starts a Python shell. You can pass in a ``make_context`` argument, which must be a ``callable`` returning a ``dict``. By default, this is just a dict returning the your Flask application instance::