From 976f9fc0fac47a613bd2da91c3ea48853e0f4a5b Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 2 Jan 2024 12:40:46 -0600 Subject: [PATCH] feat: hide stacktraces --- src/viv/viv.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index 5d2f6f6..3d4ec28 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -2173,9 +2173,20 @@ class Cli: ) +def _no_traceback_excepthook(exc_type, exc_val, traceback): + # https://stackoverflow.com/questions/7073268/remove-traceback-in-python-on-ctrl-c + pass + + def main() -> None: - viv = Viv() - Cli(viv).run() + try: + viv = Viv() + Cli(viv).run() + except KeyboardInterrupt: + echo(f"caught {a.bold}SIGINT") + if sys.excepthook is sys.__excepthook__: + sys.excepthook = _no_traceback_excepthook + raise if __name__ == "__main__":