feat(cli): add --json flag to flask routes command#6003
Closed
sahilmalhotra1987 wants to merge 1 commit intopallets:mainfrom
Closed
feat(cli): add --json flag to flask routes command#6003sahilmalhotra1987 wants to merge 1 commit intopallets:mainfrom
sahilmalhotra1987 wants to merge 1 commit intopallets:mainfrom
Conversation
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>
Member
No thanks. If we wanted AI-generated code, we could just use these tools ourselves. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--jsonflag toflask routesthat outputs the route table as a JSON array instead of the text tableendpoint,methods(sorted list), andrule; subdomain apps also emitsubdomain, host-matching apps emithostHEADandOPTIONSare filtered unless--all-methodsis also passed; empty apps produce[]--sortflag is honoured in JSON mode (matchpreserves naturaliter_rules()order)flask routesinvocations are unaffectedTest plan
test_json_output— basic shape: keysendpoint,methods,rulepresent; methods is a listtest_json_no_routes— empty app returns[]test_json_excludes_head_options_by_default— HEAD/OPTIONS absent without--all-methodstest_json_all_methods— HEAD/OPTIONS present with--all-methodstest_json_with_subdomain—subdomainkey present and correct valuetest_json_with_host_matching—hostkey present and correct valuetest_json_sort(parametrized) —endpointandrulesort keys produce sorted outputtest_json_sort_match_preserves_iter_rules_order—--sort matchpreserves natural route order🤖 Generated with Claude Code