1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

add pager functionality to parser documentation

This commit is contained in:
Kelly Brazil
2022-07-15 11:18:02 -07:00
parent 6573b355cc
commit a7ee414c67
2 changed files with 14 additions and 3 deletions

View File

@ -225,9 +225,11 @@ def help_doc(options):
f'Compatibility: {compatible}\n\n'\
f'Version {version} by {author} ({author_email})\n'
return doc_text
utils._safe_pager(doc_text)
return
return helptext()
utils._safe_print(helptext())
return
def versiontext():
@ -504,7 +506,7 @@ def main():
sys.exit(0)
if help_me:
utils._safe_print(help_doc(sys.argv))
help_doc(sys.argv)
sys.exit(0)
if version_info:

View File

@ -29,6 +29,15 @@ def _safe_print(string: str, sep=' ', end='\n', file=sys.stdout, flush=False) ->
print(_asciify(string), sep=sep, end=end, file=file, flush=flush)
def _safe_pager(string: str) -> None:
"""Pager output for both UTF-8 and ASCII encoding systems"""
from pydoc import pager
try:
pager(string)
except UnicodeEncodeError:
pager(_asciify(string))
def warning_message(message_lines: List[str]) -> None:
"""
Prints warning message to `STDERR` for non-fatal issues. The first line