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
|
|
||||||
|
|
||||||
|
|
||||||
bp = Blueprint('cli', 'cli')
|
|
||||||
|
|
||||||
@bp.cli.command('init')
|
def cli(app):
|
||||||
|
@app.cli.command('init')
|
||||||
def init():
|
def init():
|
||||||
import app.models
|
import xmrbackers.models
|
||||||
|
from xmrbackers.factory import db
|
||||||
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