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:
@ -225,9 +225,11 @@ def help_doc(options):
|
|||||||
f'Compatibility: {compatible}\n\n'\
|
f'Compatibility: {compatible}\n\n'\
|
||||||
f'Version {version} by {author} ({author_email})\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():
|
def versiontext():
|
||||||
@ -504,7 +506,7 @@ def main():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if help_me:
|
if help_me:
|
||||||
utils._safe_print(help_doc(sys.argv))
|
help_doc(sys.argv)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if version_info:
|
if version_info:
|
||||||
|
@ -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)
|
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:
|
def warning_message(message_lines: List[str]) -> None:
|
||||||
"""
|
"""
|
||||||
Prints warning message to `STDERR` for non-fatal issues. The first line
|
Prints warning message to `STDERR` for non-fatal issues. The first line
|
||||||
|
Reference in New Issue
Block a user