2025-05-18 12:20:14 -05:00

21 lines
575 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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]