import click
from flask.cli import FlaskGroup
from flask_alembic import Alembic


{% if models %}
def _create_flask_app(_):
    from {{ name }} import create_app
    app = create_app()
    Alembic(app)
    return app
{% else %}
def _create_flask_app(_):
    from {{ name }} import create_app
    return create_app()
{% endif %}


@click.group(cls=FlaskGroup, create_app=_create_flask_app)
def cli():
    pass


@cli.command()
def hello():
    print('Hello world')


if __name__ == '__main__':
    cli()
