added subdomain to the "flask routes" command

This commit is contained in:
5.413U14M4N 2023-04-07 18:01:16 +05:30
parent daf6966c89
commit 0038ea3561

View file

@ -1018,20 +1018,20 @@ def routes_command(sort: str, all_methods: bool) -> None:
for rule in rules for rule in rules
] ]
headers = ("Endpoint", "Methods", "Rule") headers = ("Sub Domain","Endpoint", "Methods", "Rule")
widths = ( widths = (
max(len(rule.subdomain) for rule in rules),
max(len(rule.endpoint) for rule in rules), max(len(rule.endpoint) for rule in rules),
max(len(methods) for methods in rule_methods), max(len(methods) for methods in rule_methods),
max(len(rule.rule) for rule in rules), max(len(rule.rule) for rule in rules),
) )
widths = [max(len(h), w) for h, w in zip(headers, widths)] widths = [max(len(h), w) for h, w in zip(headers, widths)]
row = "{{0:<{0}}} {{1:<{1}}} {{2:<{2}}}".format(*widths) row = "{{0:<{0}}} {{1:<{1}}} {{2:<{2}}} {{3:<{3}}}".format(*widths)
click.echo(row.format(*headers).strip()) click.echo(row.format(*headers).strip())
click.echo(row.format(*("-" * width for width in widths))) click.echo(row.format(*("-" * width for width in widths)))
for rule, methods in zip(rules, rule_methods): for rule, methods in zip(rules, rule_methods):
click.echo(row.format(rule.endpoint, methods, rule.rule).rstrip()) click.echo(row.format(rule.subdomain, rule.endpoint, methods, rule.rule).rstrip())
cli = FlaskGroup( cli = FlaskGroup(