import sys

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.migrate import Migrate

from finny.boot import load_runner, load_environment_config

db = SQLAlchemy()
migrate = Migrate()

def create_app(name, env, runner):
  app = Flask(__name__)

  load_environment_config(app, env)

  db.init_app(app)
  load_runner(name, app, runner)
  migrate.init_app(app, db)

  return app
