21 lines
575 B
Python
21 lines
575 B
Python
# plugins/cli/routes.py
|
||
|
||
import click
|
||
from flask.cli import with_appcontext
|
||
from app.extensions import db
|
||
from plugins.plant.models import Plant
|
||
|
||
@click.command('preload-data')
|
||
@with_appcontext
|
||
def preload_data():
|
||
"""Preloads plant data into the database."""
|
||
if not Plant.query.first():
|
||
db.session.add(Plant(name="Example Plant"))
|
||
db.session.commit()
|
||
click.echo("✅ Preloaded sample plant.")
|
||
else:
|
||
click.echo("ℹ️ Plant data already exists.")
|
||
|
||
# Export command(s) so __init__.py can register them
|
||
cli_commands = [preload_data]
|