import sys
import os
import click
from app import config
from sqlmodel import Session
from sqlmodel import create_engine
from app.models.server import Server
from sqlmodel import select

API_ENVIRONMENT = os.environ.get("API_ENVIRONMENT", "Testing")
settings = getattr(sys.modules[__name__].config, API_ENVIRONMENT)

engine = create_engine(settings.DATABASE_URI)


@click.group()
@click.pass_context
def main():
    pass


@main.command(name="settings")
def get_settings():
    """
    Prints current API settings from $API_ENVIRONMENT.
    """
    click.echo(settings)


@main.group(name="import")
def import_group():
    pass

@import_group.command(name="catagories")
def import_catagories():
    """
    Commands for importing a database.
    """

    import yaml
    from app.models.server import Catagory, ServerCatagoryLink
    print("Looking for catagories.yml")

    with 