[Piglit] [PATCH] framework/programs/run.py: fix help message generation
Dylan Baker
baker.dylan.c at gmail.com
Thu Sep 18 12:13:52 PDT 2014
Any objections?
On Tuesday, September 16, 2014 01:44:30 PM Dylan Baker wrote:
> In commit 78628572 the argument parser for piglit run and piglit-run.py
> were split into two parsers to allow piglit.conf to be loaded before any
> additional parsing was done. This had the unintended side effect of
> breaking the -h/--help option since the first very limited parser took
> that option.
>
> This commit fixes this by having the first parser not generate a help
> message. This means that when it parses the command line for arguments
> it knows it skips help, and passes it on to the main parser. The main
> parser has been augmented with a dummy version of the config file option
> so that option will show up in the help message.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
> framework/programs/run.py | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/framework/programs/run.py b/framework/programs/run.py
> index 9a6276f..021443a 100644
> --- a/framework/programs/run.py
> +++ b/framework/programs/run.py
> @@ -94,12 +94,11 @@ def _run_parser(input_):
> """ Parser for piglit run command """
> # Parse the config file before any other options, this allows the config
> # file to be used to sete default values for the parser.
> - parser = argparse.ArgumentParser()
> + parser = argparse.ArgumentParser(add_help=False)
> parser.add_argument("-f", "--config",
> dest="config_file",
> type=argparse.FileType("r"),
> - help="Optionally specify a piglit config file to use. "
> - "Default is piglit.conf")
> + help="override piglit.conf search path")
> known, unparsed = parser.parse_known_args(input_)
>
> # Read the config file
> @@ -163,6 +162,12 @@ def _run_parser(input_):
> parser.add_argument("-s", "--sync",
> action="store_true",
> help="Sync results to disk after every test")
> + # -f/--config is a duplicate that cannot be hit, but is needed for help
> + # generation
> + parser.add_argument("-f", "--config",
> + metavar="config_file",
> + dest="__unused",
> + help="override piglit.conf search path")
> parser.add_argument("test_profile",
> metavar="<Path to one or more test profile(s)>",
> nargs='+',
> --
> 2.1.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140918/0979b79e/attachment.sig>
More information about the Piglit
mailing list