From 4c13ec71215db0a98783d02abe8660110740dd91 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 24 Feb 2015 19:32:37 +0100 Subject: [PATCH] validate:launcher: Print the long help in less when possible --- validate/launcher/main.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/validate/launcher/main.py b/validate/launcher/main.py index 1c5be15..f04bd8f 100644 --- a/validate/launcher/main.py +++ b/validate/launcher/main.py @@ -18,10 +18,12 @@ # Boston, MA 02110-1301, USA. import os import re +import sys import utils import urlparse import loggable import argparse +import tempfile import reporters import subprocess @@ -29,9 +31,10 @@ import subprocess from loggable import Loggable from httpserver import HTTPServer from baseclasses import _TestsLauncher, ScenarioManager -from utils import printc, path2url, DEFAULT_MAIN_DIR, launch_command, Colors, Protocols +from utils import printc, path2url, DEFAULT_MAIN_DIR, launch_command, Colors, Protocols, which +LESS = "less" HELP = ''' =============================================================================== @@ -307,7 +310,7 @@ class LauncherConfig(Loggable): def set_http_server_dir(self, path): if self.http_server_dir is not None: - princ("Server directory already set to %s" % self.http_server_dir) + printc("Server directory already set to %s" % self.http_server_dir) return self.http_server_dir = path @@ -327,9 +330,15 @@ class LauncherConfig(Loggable): def main(libsdir): + if "--help" in sys.argv: + _help_message = HELP + else: + _help_message = "Use --help for the full help" + parser = argparse.ArgumentParser( formatter_class=argparse.RawTextHelpFormatter, - prog='gst-validate-launcher', description=HELP) + prog='gst-validate-launcher', description=_help_message) + parser.add_argument('testsuites', metavar='N', nargs='*', help="""Lets you specify a file where the testsuite to execute is defined. @@ -470,6 +479,12 @@ Note that all testsuite should be inside python modules, so the directory should loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) + if _help_message == HELP and which(LESS): + tmpf = tempfile.NamedTemporaryFile() + + parser.print_help(file=tmpf) + exit(os.system("%s %s" % (LESS, tmpf.name))) + tests_launcher = _TestsLauncher(libsdir) tests_launcher.add_options(parser) -- 2.7.4