Files
sigl/sigl/cli.py
2022-07-14 17:17:11 -07:00

40 lines
904 B
Python

"""Sigl Flask Shell Helpers.
Simple Grocery List (Sigl) | sigl.app
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
"""
def init_shell(): # pragma: no cover
"""Initialize the Flask Shell Context."""
import datetime
import sqlalchemy as sa
from sigl.database import db
from sigl.domain.models import ListEntry, Product, ProductLocation, ShoppingList
return {
# Imports
'datetime': datetime,
'sa': sa,
# Globals
'db': db,
'session': db.session,
# Models
'ListEntry': ListEntry,
'Product': Product,
'ProductLocation': ProductLocation,
'ShoppingList': ShoppingList,
}
def init_cli(app):
"""Register the Shell Helpers with the Application."""
app.shell_context_processor(init_shell)
# Notify Initialization Complete
app.logger.debug('CLI Initialized')