Replace sys.exit() with click.Context.fail()
Use click methods which gives a better output result, and for consistency and potentially using an other interface.
fail()abort()exit()close()
Write function in tools.py:
from rich_click import click
def fail(message: str) -> None:
click.get_current_context().fail(message)
The context has to be defined in the function otherwise it does not work.
Edited by Moul