29 lines
814 B
Python
29 lines
814 B
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|
|
|
from nouri import create_app
|
|
from nouri.reminders import reminder_worker_loop, send_due_meal_pushes
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="Run Nouri meal reminder pushes.")
|
|
parser.add_argument("--once", action="store_true", help="Run one reminder cycle and exit.")
|
|
parser.add_argument("--sleep", type=int, default=60, help="Seconds between reminder cycles.")
|
|
args = parser.parse_args()
|
|
|
|
app = create_app()
|
|
with app.app_context():
|
|
if args.once:
|
|
send_due_meal_pushes()
|
|
return
|
|
reminder_worker_loop(sleep_seconds=max(15, args.sleep))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|