diff --git a/src/tldr_man/main.py b/src/tldr_man/main.py index c6e3cb2..f6d3964 100755 --- a/src/tldr_man/main.py +++ b/src/tldr_man/main.py @@ -63,6 +63,9 @@ def wrapper(ctx: Context, _param, value): # If `sys.exit()` was called, exit that context with the given status code. exited_with_error = True # Don't call the `ctx.exit()` in the `finally` block ctx.exit(err.code) + except KeyboardInterrupt: + exited_with_error = True + ctx.exit(130) finally: if not exited_with_error: ctx.exit() diff --git a/src/tldr_man/pages.py b/src/tldr_man/pages.py index b0ec5d4..bebacb0 100644 --- a/src/tldr_man/pages.py +++ b/src/tldr_man/pages.py @@ -274,7 +274,7 @@ def pandoc_exists() -> bool: def verify_tldr_cache_exists(): """Display a specific message if the tldr manpage cache doesn't exist yet, and then exit.""" if not CACHE_DIR.exists(): - exit_with(CACHE_DOES_NOT_EXIST_MESSAGE) + exit_with(CACHE_DOES_NOT_EXIST_MESSAGE, exitcode=3) def display_page(page: Path) -> None: @@ -294,7 +294,7 @@ def find_page(page_name: str, /, locales: Iterable[str], page_sections: Iterable if page.exists(): return page else: - eprint(PAGE_NOT_FOUND_MESSAGE.format(page_name=page_name)) + exit_with(PAGE_NOT_FOUND_MESSAGE.format(page_name=page_name)) def get_dir_search_order(locales: Iterable[str], page_sections: Iterable[str]) -> Iterable[Path]: