#! /usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import click
import shutil
import sys

from project_name.config import config


@click.group()
def cli():
    pass


@cli.command()
def gunicorn():
    """ run gunicorn server """
    # run flask app
    executable = shutil.which("gunicorn")
    config_file = config.get("gunicorn", "config_file")
    command = [executable, "--config", config_file, "project_name"]
    subprocess.run(command, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)


if __name__ == "__main__":
    cli()
