/
manager.py
43 lines (32 loc) · 1.25 KB
/
manager.py
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
38
39
40
41
42
43
from functools import partial
from flaskext.script import Manager, Server, Shell
from werkzeug import create_environ
from coqd.runner import main as coqd_main
from cockerel.webapp import app
from cockerel.utilities import new_app
from cockerel.models import db, schema
def _make_context():
return dict(app=new_app(app), db=db, models=schema)
manager = Manager(partial(new_app, app))
manager.add_command("shell", Shell(make_context=_make_context))
manager.add_command("runserver", Server())
manager.add_option('--serialize', action="store_true",
default=False, help="Serialize output to JSON")
@manager.command
def initdb():
# A request_context is required to use these helper functions
with new_app(app).request_context(create_environ()):
db.drop_all()
db.create_all()
@manager.option("--module", dest="modules", action="append",
default=[],
help="load modules into coqd, more than one "
"can be specified",
)
@manager.option('--serialize', action="store_true",
default=False,
help="Serialize output to JSON")
def runcoqd(modules, serialize):
coqd_main(modules, serialize)
if __name__ == "__main__":
manager.run()