nopaque/app/cli.py

37 lines
801 B
Python
Raw Normal View History

from .models import Role
from flask_migrate import upgrade
def register(app):
@app.cli.command()
def deploy():
"""Run deployment tasks."""
# migrate database to latest revision
upgrade()
# create or update user roles
Role.insert_roles()
@app.cli.group()
def daemon():
"""Daemon commands."""
pass
@daemon.command()
def run():
"""Run daemon"""
from app.daemon import Daemon
daemon = Daemon()
daemon.run()
@app.cli.group()
def test():
"""Test commands."""
pass
@test.command()
def run():
"""Run unit tests."""
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)