# Path: clearly/utils/logo.py
# CLEARLY_LOGO = r'''
#         __                __
#   _____/ /__  ____ ______/ /_  __
#  / ___/ / _ \/ __ `/ ___/ / / / /
# / /__/ /  __/ /_/ / /  / / /_/ /
# \___/_/\___/\__,_/_/  /_/\__, /
#                         /____/
# '''
# SYSTEMS_LOGO = dict(
#     client=r'''
#       ___          __ 
#  ____/ (_)__ ___  / /_
# / __/ / / -_) _ \/ __/
# \__/_/_/\__/_//_/\__/ 
# ''',
#     server=r'''
#  ___ ___ _____  _____ ____
# (_-</ -_) __/ |/ / -_) __/
# \__/\__/_/  |___/\__/_/   
# ''',
# )
# def render(system: str) -> str:
# 
# Path: clearly/utils/colors.py
# class Colors:
#     BLUE = color_factory('\033[94m')
#     GREEN = color_factory('\033[92m')
#     YELLOW = color_factory('\033[93m')
#     RED = color_factory('\033[91m')
#     MAGENTA = color_factory('\033[95m')
#     CYAN = color_factory('\033[96m')
#     ORANGE = color_factory('\033[38;5;208m')
# 
#     BOLD = color_factory('\033[1m')
#     DIM = color_factory('\033[2m')
# 
#     BLUE_BOLD, BLUE_DIM = BLUE.mix(BOLD, DIM)
#     GREEN_BOLD, GREEN_DIM = GREEN.mix(BOLD, DIM)
#     YELLOW_BOLD, YELLOW_DIM = YELLOW.mix(BOLD, DIM)
#     RED_BOLD, RED_DIM = RED.mix(BOLD, DIM)
#     MAGENTA_BOLD, MAGENTA_DIM = MAGENTA.mix(BOLD, DIM)
#     CYAN_BOLD, CYAN_DIM = CYAN.mix(BOLD, DIM)
#     ORANGE_BOLD, ORANGE_DIM = ORANGE.mix(BOLD, DIM)


import logging
import click
    import IPython
from typing import Optional
from .utils import logo
from .utils.colors import Colors
    from clearly.server import ClearlyServer
    from clearly.client import ClearlyClient, ModeTask, ModeWorker
    from traitlets.config.loader import Config



logger = logging.getLogger(__name__)


class AliasedGroup(click.Group):
    """Used to allow calling shortened commands, as long as they're unique.
     Based on recipe from http://click.palletsprojects.com/en/7.x/advanced/
    """

    def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Command]:
        rv = click.Group.get_command(self, ctx, cmd_name)
        if rv is not None:
            return rv
        matches = [x for x in self.list_commands(ctx) if x.startswith(cmd_name)]
        if not matches:
            return
        if len(matches) > 1:
            ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))
        return click.Group.get_command(self, ctx, matches[0])


def _setup_logging(debug: bool) -> None:  # pragma: no cover

# Path: clearly/utils/logo.py
# CLEARLY_LOGO = r'''
#         __                __
#   _____/ /__  ____ ______/ /_  __
#  / ___/ / _ \/ __ `/ ___/ / / / /
# / /__/ /  __/ /_/ / /  / / /_/ /
# \___/_/\___/\__,_/_/  /_/\__, /
#                         /____/
# '''
# SYSTEMS_LOGO = dict(
#     client=r'''
#       ___          __ 
#  ____/ (_)__ ___  / /_
# / __/ / / -_) _ \/ __/
# \__/_/_/\__/_//_/\__/ 
# ''',
#     server=r'''
#  ___ ___ _____  _____ ____
# (_-</ -_) __/ |/ / -_) __/
# \__/\__/_/  |___/\__/_/   
# ''',
# )
# def render(system: str) -> str:
# 
# Path: clearly/utils/colors.py
# class Colors:
#     BLUE = color_factory('\033[94m')
#     GREEN = color_factory('\033[92m')
#     YELLOW = color_factory('\033[93m')
#     RED = color_factory('\033[91m')
#     MAGENTA = color_factory('\033[95m')
#     CYAN = color_factory('\033[96m')
#     ORANGE = color_factory('\033[38;5;208m')
# 
#     BOLD = color_factory('\033[1m')
#     DIM = color_factory('\033[2m')
# 
#     BLUE_BOLD, BLUE_DIM = BLUE.mix(BOLD, DIM)
#     GREEN_BOLD, GREEN_DIM = GREEN.mix(BOLD, DIM)
#     YELLOW_BOLD, YELLOW_DIM = YELLOW.mix(BOLD, DIM)
#     RED_BOLD, RED_DIM = RED.mix(BOLD, DIM)
#     MAGENTA_BOLD, MAGENTA_DIM = MAGENTA.mix(BOLD, DIM)
#     CYAN_BOLD, CYAN_DIM = CYAN.mix(BOLD, DIM)
#     ORANGE_BOLD, ORANGE_DIM = ORANGE.mix(BOLD, DIM)


# Path: clearly/command_line.py
import logging
import click
    import IPython
from typing import Optional
from .utils import logo
from .utils.colors import Colors
    from clearly.server import ClearlyServer
    from clearly.client import ClearlyClient, ModeTask, ModeWorker
    from traitlets.config.loader import Config




logger = logging.getLogger(__name__)


class AliasedGroup(click.Group):
    """Used to allow calling shortened commands, as long as they're unique.
     Based on recipe from http://click.palletsprojects.com/en/7.x/advanced/
    """

    def get_command(self, ctx: click.Context, cmd_name: str) -> Optional[click.Command]:
        rv = click.Group.get_command(self, ctx, cmd_name)
        if rv is not None:
            return rv
        matches = [x for x in self.list_commands(ctx) if x.startswith(cmd_name)]
        if not matches:
            return
        if len(matches) > 1:
            ctx.fail('Too many matches: %s' % ', '.join(sorted(matches)))
        return click.Group.get_command(self, ctx, matches[0])


def _setup_logging(debug: bool) -> None:  # pragma: no cover

    f = Colors.DIM('%(asctime)s') + Colors.MAGENTA(' %(name)s') \