From 8fffbb52a5d4712b3f77e7600a9fcfe1cfc276c2 Mon Sep 17 00:00:00 2001 From: Joe Kaufeld Date: Tue, 16 Aug 2022 13:17:43 -0400 Subject: [PATCH] better exceptions --- src/cli.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/cli.py b/src/cli.py index b84e4be..ac243ce 100644 --- a/src/cli.py +++ b/src/cli.py @@ -7,7 +7,7 @@ import uuid import click import httpx from rich import pretty -from rich import print # yes, deliberately shadow `print` +from rich.traceback import install from shiv.bootstrap import current_zipfile import src @@ -24,24 +24,12 @@ from src.art import BANNERS def main(ctx): """Launch a utility or drop into a command line REPL if no command is given.""" if ctx.invoked_subcommand is None: - def print_wrapper(*args, **kwargs): - # I know this is dumb. - # https://github.com/Textualize/rich/discussions/2462 - if "crop" in kwargs: - del kwargs["crop"] - print(*args, **kwargs) - banner = random.choice(BANNERS) - # source of code.interact, just expanded to fit Rich in there - console = code.InteractiveConsole(globals()) - console.print = print_wrapper - pretty.install(console) # type: ignore - try: - import readline - except ImportError: - pass - console.interact(banner, None) + pretty.install() # type: ignore + install() # traceback handler + + code.interact(banner, None) sys.exit()