From 5fe50f9a4018f21d36e3ef34d7af9f7b5d7016b9 Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Wed, 8 Sep 2021 12:38:01 +0100 Subject: tools: Refactor full help printing Collect the code for printing the full help message of patman, buildman and binman into a single function in patman.tools. Signed-off-by: Paul Barker --- tools/patman/tools.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools/patman/tools.py') diff --git a/tools/patman/tools.py b/tools/patman/tools.py index 877e37cd8da..96882264a2f 100644 --- a/tools/patman/tools.py +++ b/tools/patman/tools.py @@ -581,3 +581,16 @@ def ToHexSize(val): hex value of size, or 'None' if the value is None """ return 'None' if val is None else '%#x' % len(val) + +def PrintFullHelp(fname): + """Print the full help message for a tool using an appropriate pager. + + Args: + fname: Path to a file containing the full help message + """ + pager = os.getenv('PAGER') + if not pager: + pager = shutil.which('less') + if not pager: + pager = 'more' + command.Run(pager, fname) -- cgit v1.2.3