add option to flask scodoc-database

This commit is contained in:
Jean-Marie Place 2021-10-03 10:03:55 +02:00 committed by Jean-Marie Place
parent f619dfec36
commit a455a61910
1 changed files with 14 additions and 4 deletions

View File

@ -275,10 +275,20 @@ def list_depts(depts=""): # list-dept
@app.cli.command()
def scodoc_database_uri(): # list-dept
"""print the database_uril
"""
print(app.config["SQLALCHEMY_DATABASE_URI"])
@click.option(
"-n",
"--name",
is_flag=True,
help="show database name instead of connexion string (required for "
"dropdb/createddb commands)",
)
def scodoc_database(name): # list-dept
"""print the database connexion string"""
uri = app.config["SQLALCHEMY_DATABASE_URI"]
if name:
print(uri.split("/")[-1])
else:
print(uri)
@app.cli.command()