wire up cli functionality
parent
a3fda7c4ed
commit
0dd2326bab
@ -1,30 +1,11 @@
|
|||||||
import click
|
import click
|
||||||
from quart import Blueprint, current_app
|
|
||||||
|
|
||||||
from xmrbackers.models import Creator
|
|
||||||
from xmrbackers.factory import db
|
|
||||||
|
|
||||||
|
def cli(app):
|
||||||
bp = Blueprint('cli', 'cli')
|
@app.cli.command('init')
|
||||||
|
def init():
|
||||||
@bp.cli.command('init')
|
import xmrbackers.models
|
||||||
def init():
|
from xmrbackers.factory import db
|
||||||
import app.models
|
|
||||||
db.create_all()
|
db.create_all()
|
||||||
|
|
||||||
@bp.cli.command('delete')
|
return app
|
||||||
@click.argument('thing_id')
|
|
||||||
def delete(thing_id):
|
|
||||||
thing = Creator.query.get(thing_id)
|
|
||||||
if thing:
|
|
||||||
db.session.delete(thing)
|
|
||||||
db.session.commit()
|
|
||||||
click.echo(f'Creator {thing.id} was deleted')
|
|
||||||
else:
|
|
||||||
click.echo('Creator ID does not exist')
|
|
||||||
|
|
||||||
@bp.cli.command('list')
|
|
||||||
def list_things():
|
|
||||||
thing = Creator.query.all()
|
|
||||||
for i in thing:
|
|
||||||
click.echo(i.id)
|
|
||||||
|
Loading…
Reference in New Issue