#!/usr/bin/env python

import os
import argparse

__author__ = "Shyue Ping Ong"
__copyright__ = "Copyright 2016, The Materials Virtual Lab"
__version__ = "0.1"
__maintainer__ = "Shyue Ping Ong"
__email__ = "shyuep@gmail.com"
__date__ = "2/27/2016"


if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="""flamyngo is a basic Flask frontend for querying
        MongoDB collections.""",
        epilog="Author: Shyue Ping Ong")

    parser.add_argument(
        "-c", "--config", dest="config", type=str, nargs="?",
        default=os.path.join(os.environ["HOME"], ".flamyngo.yaml"),
        help="YAML file where the config is stored")
    parser.add_argument(
        "-p", "--port", dest="port", type=int, nargs="?",
        default=5000,
        help="Port in which to run the server. Defaults to 5000.")

    args = parser.parse_args()

    os.environ["FLAMYNGO"] = args.config
    from flamyngo import app
    app.run(debug=True, host='0.0.0.0', port=args.port)

