Remove the `--eager-loading/--lazy-loading` options and the
`DispatchingApp` middleware. The `run` command handles loading
exceptions directly. The reloader always prints out tracebacks
immediately and always defers raising the error.
As long as popular libraries (e.g. Celery) require click 7, depending
on Click 8 in Flask makes it hard to test the latest version (and its
other dependencies) in existing applications.
When loading the app fails for the --help command, only the error
message is shown, then the help text. The full traceback is shown for
other exceptions. Also show the message when loading fails while
getting a command, instead of only "command not found". The error
message goes to stderr to match other error behavior, and is in red
with an extra newline to make it more obvious next to the help text.
Also fixes an issue with the test_apps fixture that caused an imported
app to still be importable after the test was over and the path was
reset. Now the module cache is reset as well.
Flask currently supports importing app through a combination of module
path and app variable name, such as '/usr/app.py:my_app'. When the
module path contains a colon, it will conflict with this import way and
a `flask.cli.NoAppException` will be raised.
A file path on a Windows system may contain a colon followed by a slash.
So we solved this problem on Windows by ignoring the colon followed by a
slash when we split app_import_path.
Fix issue #2961.
This is mainly intended for custom CLIs that may load a config file
which already sets the debug flag and does not make use of the `FLASK_*`
env vars at all.