Skip to content

printer

dandy.cli.tui.printer

Printer

Source code in dandy/cli/tui/printer.py
def __init__(self, terminal: Terminal) -> None:
    self.term = terminal

term = terminal instance-attribute

blank_line staticmethod

Source code in dandy/cli/tui/printer.py
@staticmethod
def blank_line():
    print(flush=True)

blue_divider

Source code in dandy/cli/tui/printer.py
def blue_divider(self):
    print(self.term.bold_blue('─' * self.term.width), flush=True)

purple_divider

Source code in dandy/cli/tui/printer.py
def purple_divider(self):
    print(self.term.bold_purple('─' * self.term.width), flush=True)

divider

Source code in dandy/cli/tui/printer.py
def divider(self):
    print(self.term.bold_grey('─' * self.term.width), flush=True)

green_divider

Source code in dandy/cli/tui/printer.py
def green_divider(self):
    print(self.term.bold_green('─' * self.term.width), flush=True)

red_divider

Source code in dandy/cli/tui/printer.py
def red_divider(self):
    print(self.term.bold_red('─' * self.term.width), flush=True)

welcome

Source code in dandy/cli/tui/printer.py
def welcome(self):
    print(self.term.bold_blue(f'\n{DANDY_ANSII}\n'))
    self.blue_divider()
    print(self.term.bold_blue('Version      : ') + constants.__VERSION__)
    print(self.term.bold_blue('Model        : ') + LlmConfig('DEFAULT').model)
    print(self.term.bold_blue('Project Dir  : ') + str(session.project_base_path))

running_action

Source code in dandy/cli/tui/printer.py
def running_action(self, action: BaseAction):
    phrase = random.choice(PROCESSING_PHRASES)
    self.indented_event(
        text=f'{self.term.bold_blue}{phrase} in preparation of "{action.name_gerund}" ',
    )

completed_action

Source code in dandy/cli/tui/printer.py
def completed_action(self, start_time: float, action: BaseAction):
    self.indented_event(
        text=f'{self.term.bold_green}Finished in only {perf_counter() - start_time:.1f}s',
        indent=1
    )

start_task

Source code in dandy/cli/tui/printer.py
def start_task(self, action_name: str, task: str) -> float:
    self.indented_event(
        text=f'{self.term.bold_orange}{action_name}{self.term.normal} "{task}" ... ',
        indent=1,
        end='',
    )

    return perf_counter()

end_task

Source code in dandy/cli/tui/printer.py
def end_task(self, start_time: float, action_name: str = 'done'):
    print(f'{self.term.green}{action_name} {perf_counter() - start_time:.1f}s{self.term.normal}')

indented_event

Source code in dandy/cli/tui/printer.py
def indented_event(self, text: str, indent: int = 0, end: str = '\n'):
    print(f'{self.term.normal}{" " * ((indent * 2) + 1)}{text}{self.term.normal}', end=end, flush=True)

output

Source code in dandy/cli/tui/printer.py
def output(self, output: str):
    wrapped_output = wrap_text_with_indentation(output, self.term.width)

    for line in wrapped_output.splitlines():
        sleep(0.02)
        print(line)

error

Source code in dandy/cli/tui/printer.py
def error(self, error: str, description: str):
    self.indented_event(
        text=f'{self.term.red}Error: {self.term.normal}{error} !!!'
    )
    self.red_divider()
    print(f'{description}')