Skip to content
Myr

use dashes for command names

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent d5fea5f · Browse files · 1 file+15 added−15 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−15 removed

  • other:+15 added−15 removed

1 file+15 added−15 removed

modified:docs/cli.rst+15 added-15 removed
189 unmodified lines
190environment variables. The variables use the pattern191``FLASK_COMMAND_OPTION``. For example, to set the port for the run192command, instead of ``flask run --port 8000``:193194.. code-block:: none194.. code-block:: bash195196 export FLASK_RUN_PORT=8000197 flask run196 $ export FLASK_RUN_PORT=8000197 $ flask run198 * Running on http://127.0.0.1:8000/199200These can be added to the ``.flaskenv`` file just like ``FLASK_APP`` to201control default command options.
4 unmodified lines
206207The ``flask`` command will show a message if it detects dotenv files but208python-dotenv is not installed.209210.. code-block:: none210.. code-block:: bash211212 flask run212 $ flask run213 * Tip: There are .env files present. Do "pip install python-dotenv" to use them.214215You can tell Flask not to load dotenv files even when python-dotenv is216installed by setting the ``FLASK_SKIP_DOTENV`` environment variable.
1 unmodified line
218a project runner that loads them already. Keep in mind that the219environment variables must be set before the app loads or it won't220configure as expected.221222.. code-block:: none222.. code-block:: bash223224 export FLASK_SKIP_DOTENV=1225 flask run224 $ export FLASK_SKIP_DOTENV=1225 $ flask run226227228Environment Variables From virtualenv229-------------------------------------
3 unmodified lines
233script. Activating the virtualenv will set the variables.234235Unix Bash, :file:`venv/bin/activate`::236237 export FLASK_APP=hello237 $ export FLASK_APP=hello238239Windows CMD, :file:`venv\\Scripts\\activate.bat`::240241 set FLASK_APP=hello241 > set FLASK_APP=hello242243It is preferred to use dotenv support over this, since :file:`.flaskenv` can be244committed to the repository so that it works automatically wherever the project245is checked out.
4 unmodified lines
250251The ``flask`` command is implemented using `Click`_. See that project's252documentation for full information about writing commands.253254This example adds the command ``create_user`` that takes the argument254This example adds the command ``create-user`` that takes the argument255``name``. ::256257 import click258 from flask import Flask259260 app = Flask(__name__)261262 @app.cli.command()263 @click.argument('name')262 @app.cli.command("create-user")263 @click.argument("name")264 def create_user(name):265 ...266267::268269 flask create_user admin269 $ flask create-user admin270271This example adds the same command, but as ``user create``, a command in a272group. This is useful if you want to organize multiple related commands. ::273
12 unmodified lines
286 app.cli.add_command(user_cli)287288::289290 flask user create demo290 $ flask user create demo291292See :ref:`testing-cli` for an overview of how to test your custom293commands.294
172 unmodified lines