aboutsummaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
authorPaul Barker <paul.barker@sancloud.com>2021-09-08 12:38:01 +0100
committerTom Rini <trini@konsulko.com>2021-09-24 14:30:46 -0400
commit5fe50f9a4018f21d36e3ef34d7af9f7b5d7016b9 (patch)
treeeabe72bc1f7e2fc848616999485161ace286f71a /tools/patman
parent15e30106ce624ade62ba87c2defe7ea67c88f1b5 (diff)
downloadu-boot-5fe50f9a4018f21d36e3ef34d7af9f7b5d7016b9.zip
u-boot-5fe50f9a4018f21d36e3ef34d7af9f7b5d7016b9.tar.gz
u-boot-5fe50f9a4018f21d36e3ef34d7af9f7b5d7016b9.tar.bz2
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 <paul.barker@sancloud.com>
Diffstat (limited to 'tools/patman')
-rwxr-xr-xtools/patman/main.py12
-rw-r--r--tools/patman/tools.py13
2 files changed, 17 insertions, 8 deletions
diff --git a/tools/patman/main.py b/tools/patman/main.py
index 04e37a5..e5be28e 100755
--- a/tools/patman/main.py
+++ b/tools/patman/main.py
@@ -28,6 +28,7 @@ from patman import settings
from patman import terminal
from patman import test_util
from patman import test_checkpatch
+from patman import tools
epilog = '''Create patches from commits in a branch, check them and email them
as specified by tags you place in the commits. Use -n to do a dry run first.'''
@@ -170,14 +171,9 @@ elif args.cmd == 'send':
fd.close()
elif args.full_help:
- pager = os.getenv('PAGER')
- if not pager:
- pager = shutil.which('less')
- if not pager:
- pager = 'more'
- fname = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
- 'README')
- command.Run(pager, fname)
+ tools.PrintFullHelp(
+ os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README')
+ )
else:
# If we are not processing tags, no need to warning about bad ones
diff --git a/tools/patman/tools.py b/tools/patman/tools.py
index 877e37c..9688226 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)