flask icon indicating copy to clipboard operation
flask copied to clipboard

Add `--debug` option to flask run

Open greyli opened this issue 2 years ago • 3 comments

The alternative of #4778

Using flask run with --debug is common usage, and adding this option to flask run makes the command more intuitive:

flask run --debug

If this change is accepted, then I will update the docs and add tests.

Checklist:

  • [ ] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • [ ] Add or update relevant docs, in the docs folder and in code.
  • [ ] Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • [ ] Add .. versionchanged:: entries in any relevant code docs.
  • [ ] Run pre-commit hooks and fix any issues.
  • [ ] Run pytest and tox, no tests failed.

greyli avatar Aug 21 '22 09:08 greyli

It's a bit confusing to have both --debug and --debugger flags, but I'm guessing most people don't know about the second flag anyway. This mostly matches the signature for app.run, which calls them debug and use_debugger.

davidism avatar Aug 22 '22 15:08 davidism

Rebased to 2.2.x and updated docs. I'm not sure if we need to add tests here, I was thinking something like this:

@pytest.mark.parametrize(
    "option,value",
    (
        (["--debug"], True),
        (["--no-debug"], False),
    )
)
def test_run_debug(option, value):
    ctx = run_command.make_context("run", option)
    assert ctx.params["debug"] == value

But it seems unnecessary.

greyli avatar Aug 23 '22 09:08 greyli

It's a bit confusing to have both --debug and --debugger flags, but I'm guessing most people don't know about the second flag anyway. This mostly matches the signature for app.run, which calls them debug and use_debugger.

When this option was added, I think most people will use --debug over --reload and --debugger.

BTW, --reloader matches --debugger and use_reloader better. Do you think we need to rename --reload to --reloader?

greyli avatar Aug 23 '22 09:08 greyli

I agree we should change reload to reloader as well, but I want to wait until Click can show a deprecation message for individual options.

davidism avatar Dec 24 '22 22:12 davidism