Paginate --help output

This commit is contained in:
Kovid Goyal 2017-11-27 15:35:43 +05:30
parent 1d9b36996a
commit fd49d17591
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -3,6 +3,7 @@
# License: GPL v3 Copyright: 2017, Kovid Goyal <kovid at kovidgoyal.net>
import re
import subprocess
import sys
from collections import deque
@ -10,7 +11,6 @@ from .config import load_config
from .constants import appname, defconf, is_macos, str_version
from .layout import all_layouts
is_macos
OPTIONS = '''
--class
@ -271,8 +271,13 @@ def print_help_for_seq(seq):
t = opt['help'].replace('%default', str(opt.get('default')))
wa(prettify(t), indent=4)
print('\n'.join(blocks))
print('\n' + version())
text = '\n'.join(blocks) + '\n\n' + version()
if sys.stdout.isatty():
p = subprocess.Popen(['less', '-isR'], stdin=subprocess.PIPE)
p.communicate(text.encode('utf-8'))
raise SystemExit(p.wait())
else:
print(text)
def defval_for_opt(opt):