cli.py 711 Bytes
Newer Older
Nicolas Joyard committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import click


@click.group()
def cli():
    pass


@cli.command(short_help=u'Exécute le serveur web flask intégré')
def runserver():
    from .parlapi import app
    app.run()


@cli.command(short_help=u'Crée ou met à jour le schéma BDD')
def createdb():
    from .parlapi import app
    from .models import db

    with app.app_context():
        db.create_all()


@cli.command(short_help=u'Met à jour les organes depuis l\'AN')
@click.option('--force', is_flag=True)
def update_organes_an(force):
    from .parlapi import app
    from .jobs.an_organes import run

    with app.app_context():
        run(app, force)


if __name__ == '__main__':
    cli()