summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2021-06-05 21:30:05 -0400
committerZane Bitter <zbitter@redhat.com>2021-07-12 21:03:39 -0400
commit4e7c882c3cb709d8d7a52d10c6d4f31f698b0e05 (patch)
tree30dc2be3ef8b999006a782e403afda36bd63155a
parent8fa916e9169f507ce7b861f3d9df9a14734672d2 (diff)
downloadcliff-4e7c882c3cb709d8d7a52d10c6d4f31f698b0e05.tar.gz
Automatically page interactive root help output
The previous commit already ensures that the interactive help for individual commands is sent to a pager. This does the same for the 'help' command with no arguments. Change-Id: If5e38421d21e09f88a572dbb508b1997381bdb87
-rw-r--r--cliff/interactive.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/cliff/interactive.py b/cliff/interactive.py
index aca7233..0a44481 100644
--- a/cliff/interactive.py
+++ b/cliff/interactive.py
@@ -17,6 +17,7 @@ import itertools
import shlex
import sys
+import autopage.argparse
import cmd2
@@ -140,9 +141,16 @@ class InteractiveApp(cmd2.Cmd):
parsed = lambda x: x # noqa
self.default(parsed('help ' + arg))
else:
- cmd2.Cmd.do_help(self, arg)
- cmd_names = sorted([n for n, v in self.command_manager])
- self.print_topics(self.app_cmd_header, cmd_names, 15, 80)
+ stdout = self.stdout
+ try:
+ with autopage.argparse.help_pager(stdout) as paged_out:
+ self.stdout = paged_out
+
+ cmd2.Cmd.do_help(self, arg)
+ cmd_names = sorted([n for n, v in self.command_manager])
+ self.print_topics(self.app_cmd_header, cmd_names, 15, 80)
+ finally:
+ self.stdout = stdout
return
# Create exit alias to quit the interactive shell.