mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 14:58:25 -04:00
Switch existing command to standard approach
This is the suggested approach in the documentation [1] and using it makes it clearer what's going on and to add other commands with arguments, which we'll do in the next commit. [1]: https://flask.palletsprojects.com/en/2.0.x/cli/#custom-commands
This commit is contained in:
@@ -1,6 +1,10 @@
|
|||||||
|
import click
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
from flask.cli import with_appcontext
|
||||||
|
|
||||||
|
|
||||||
|
@click.command('list-routes')
|
||||||
|
@with_appcontext
|
||||||
def list_routes():
|
def list_routes():
|
||||||
"""List URLs of all application routes."""
|
"""List URLs of all application routes."""
|
||||||
for rule in sorted(current_app.url_map.iter_rules(), key=lambda r: r.rule):
|
for rule in sorted(current_app.url_map.iter_rules(), key=lambda r: r.rule):
|
||||||
@@ -8,4 +12,4 @@ def list_routes():
|
|||||||
|
|
||||||
|
|
||||||
def setup_commands(application):
|
def setup_commands(application):
|
||||||
application.cli.command('list-routes')(list_routes)
|
application.cli.add_command(list_routes)
|
||||||
|
|||||||
Reference in New Issue
Block a user