diff --git a/CHANGES.rst b/CHANGES.rst index 6a179bdf..c535a997 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -57,6 +57,9 @@ Unreleased .. _#3179: https://github.com/pallets/flask/pull/3179 .. _#3125: https://github.com/pallets/flask/pull/3125 +- Added support to ``extra_files`` argument in `flask run` CLI. (`#2898`_) + +.. _#2898: https://github.com/pallets/flask/pull/2898 Version 1.0.3 ------------- @@ -87,7 +90,6 @@ Released 2019-05-17 .. _#2933: https://github.com/pallets/flask/issues/2933 .. _#2986: https://github.com/pallets/flask/pull/2986 - Version 1.0.2 ------------- diff --git a/docs/cli.rst b/docs/cli.rst index 5835d74b..3879f6ee 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -202,6 +202,20 @@ command, instead of ``flask run --port 8000``: These can be added to the ``.flaskenv`` file just like ``FLASK_APP`` to control default command options. +To define a list of files the reloader should watch additionally to the modules +as in ``extra_files`` argument used in the ``app.run`` and ``werkzeug.serving.run_simple`` +you can either use the ``--extra-files`` (or multiple ``-f``) option or define the +``FLASK_RUN_EXTRA_FILES`` environment variable. + +.. code-block:: none + + # on windows use ``;`` instead of ``:`` to separate paths + export FLASK_RUN_EXTRA_FILES=/path/to/file1:/path/to/file2 + flask run + * Running on http://127.0.0.1:8000/ + * Detected change in '/path/to/file1', reloading + +On command line the same can be achieved with ``flask run -f /path/to/file1 -f /path/to/file2``. Disable dotenv ~~~~~~~~~~~~~~ diff --git a/flask/cli.py b/flask/cli.py index 7d882902..214eb601 100644 --- a/flask/cli.py +++ b/flask/cli.py @@ -778,8 +778,12 @@ def _validate_key(ctx, param, value): default=True, help="Enable or disable multithreading.", ) +@click.option('--extra-files', '-f', + multiple=True, default=None, type=click.Path(), + help='Files reloader should watch additionally to the modules') @pass_script_info -def run_command(info, host, port, reload, debugger, eager_loading, with_threads, cert): +def run_command(info, host, port, reload, debugger, eager_loading, + with_threads, cert, extra_files): """Run a local development server. This server is for development purposes only. It does not provide @@ -812,6 +816,7 @@ def run_command(info, host, port, reload, debugger, eager_loading, with_threads, use_debugger=debugger, threaded=with_threads, ssl_context=cert, + extra_files=extra_files )