feat(cli): add --json flag to flask routes command

Adds a machine-readable output mode to `flask routes`. When --json is
passed, the route table is emitted as a JSON array instead of the text
table. Each entry has `endpoint`, `methods` (sorted list), and `rule`;
subdomain apps also emit `subdomain`, host-matching apps emit `host`.
HEAD/OPTIONS are filtered unless --all-methods is also passed. Empty
apps produce `[]`. The --sort flag is honoured in JSON mode.

Backwards compatible: the flag is optional and all existing invocations
of `flask routes` are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sahilmalhotra1987 2026-04-19 12:11:48 +05:30
parent 2ac89889f4
commit 9536b1aeef
3 changed files with 120 additions and 5 deletions

View file

@ -3,6 +3,8 @@ Version 3.2.0
Unreleased
- The ``flask routes`` command has a ``--json`` flag to output the route
table as a JSON array, suitable for scripting and tooling.
- Drop support for Python 3.9. :pr:`5730`
- Remove previously deprecated code: ``__version__``. :pr:`5648`
- ``RequestContext`` has merged with ``AppContext``. ``RequestContext`` is now