Fix
This commit is contained in:
parent
c19bedc54a
commit
558dcfe81e
@ -34,6 +34,11 @@ def create_app():
|
|||||||
spec.loader.exec_module(mod)
|
spec.loader.exec_module(mod)
|
||||||
if hasattr(mod, 'bp'):
|
if hasattr(mod, 'bp'):
|
||||||
app.register_blueprint(mod.bp)
|
app.register_blueprint(mod.bp)
|
||||||
|
|
||||||
|
# Register CLI commands if the plugin has any
|
||||||
|
if hasattr(mod, 'cli_commands'):
|
||||||
|
for command in mod.cli_commands:
|
||||||
|
app.cli.add_command(command)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
20
plugins/cli/routes.py
Normal file
20
plugins/cli/routes.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# 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]
|
Loading…
x
Reference in New Issue
Block a user