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
Provenance
- Commit
146df0f- Tree
bcedaee- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent
d5fea5f
1 file changed+15 added−15 removed
modified:docs/cli.rst+15 added-15 removed
189 unmodified lines190 environment variables. The variables use the pattern191 ``FLASK_COMMAND_OPTION``. For example, to set the port for the run192 command, instead of ``flask run --port 8000``:193 194-.. code-block:: none194+.. code-block:: bash195 196- export FLASK_RUN_PORT=8000197- flask run196+ $ export FLASK_RUN_PORT=8000197+ $ flask run198 * Running on http://127.0.0.1:8000/199 200 These can be added to the ``.flaskenv`` file just like ``FLASK_APP`` to201 control default command options.4 unmodified lines206 207 The ``flask`` command will show a message if it detects dotenv files but208 python-dotenv is not installed.209 210-.. code-block:: none210+.. code-block:: bash211 212- flask run212+ $ flask run213 * Tip: There are .env files present. Do "pip install python-dotenv" to use them.214 215 You can tell Flask not to load dotenv files even when python-dotenv is216 installed by setting the ``FLASK_SKIP_DOTENV`` environment variable.1 unmodified line218 a project runner that loads them already. Keep in mind that the219 environment variables must be set before the app loads or it won't220 configure as expected.221 222-.. code-block:: none222+.. code-block:: bash223 224- export FLASK_SKIP_DOTENV=1225- flask run224+ $ export FLASK_SKIP_DOTENV=1225+ $ flask run226 227 228 Environment Variables From virtualenv229 -------------------------------------3 unmodified lines233 script. Activating the virtualenv will set the variables.234 235 Unix Bash, :file:`venv/bin/activate`::236 237- export FLASK_APP=hello237+ $ export FLASK_APP=hello238 239 Windows CMD, :file:`venv\\Scripts\\activate.bat`::240 241- set FLASK_APP=hello241+ > set FLASK_APP=hello242 243 It is preferred to use dotenv support over this, since :file:`.flaskenv` can be244 committed to the repository so that it works automatically wherever the project245 is checked out.4 unmodified lines250 251 The ``flask`` command is implemented using `Click`_. See that project's252 documentation for full information about writing commands.253 254-This example adds the command ``create_user`` that takes the argument254+This example adds the command ``create-user`` that takes the argument255 ``name``. ::256 257 import click258 from flask import Flask259 260 app = Flask(__name__)261 262- @app.cli.command()263- @click.argument('name')262+ @app.cli.command("create-user")263+ @click.argument("name")264 def create_user(name):265 ...266 267 ::268 269- flask create_user admin269+ $ flask create-user admin270 271 This example adds the same command, but as ``user create``, a command in a272 group. This is useful if you want to organize multiple related commands. ::273 12 unmodified lines286 app.cli.add_command(user_cli)287 288 ::289 290- flask user create demo290+ $ flask user create demo291 292 See :ref:`testing-cli` for an overview of how to test your custom293 commands.294 172 unmodified lines