#! /usr/bin/env python3

from argparse import ArgumentParser
import logging

from rich.console import Console
from rich.logging import RichHandler

import grn.core.gpu_master


log = logging.getLogger(__file__)


LOGGING_FORMAT = '%(message)s'
WELCOME_STR = """
   ____  ____   _   _        ____  ____   _   _           __  __              _              
  / ___||  _ \ | \ | |  _   / ___||  _ \ | | | |         |  \/  |  __ _  ___ | |_  ___  _ __ 
 | |  _ | |_) ||  \| | (_) | |  _ | |_) || | | |  _____  | |\/| | / _` |/ __|| __|/ _ \| '__|
 | |_| ||  _ < | |\  |  _  | |_| ||  __/ | |_| | |_____| | |  | || (_| |\__ \| |_|  __/| |   
  \____||_| \_\|_| \_| (_)  \____||_|     \___/          |_|  |_| \__,_||___/ \__|\___||_|   
"""
WELCOME_STR_STYLE = '#B87333'


def start():
    parser = ArgumentParser()
    parser.add_argument('--debug', action='store_true')
    args = parser.parse_args()

    logging.basicConfig(
        level=(logging.DEBUG if args.debug else logging.INFO),
        format=LOGGING_FORMAT, 
        handlers=[RichHandler(
            locals_max_string=None, 
            tracebacks_word_wrap=False)])
    
    console = Console()
    console.print(WELCOME_STR, style=WELCOME_STR_STYLE)

    log.debug('DEBUG MODE')
    grn.core.gpu_master.serve(debug=args.debug)

if __name__ == '__main__':
    start()