Commit ce5f7d42 authored by ariblue's avatar ariblue Committed by Commit bot

Fixes --output-format default case.

From python optparse docs for action='append':

"It also means that if the default value is non-empty, the default
elements will be present in the parsed value for the option, with any
values from the command line appended after those default values:"

So, to actually create a default, we have to set it later in
CreateResults. Unfortunate, but true. Thanks vogelheim@ for catching
this.

BUG=

Review URL: https://codereview.chromium.org/585023002

Cr-Commit-Position: refs/heads/master@{#295782}
parent 9980243c
...@@ -26,8 +26,7 @@ def AddResultsOptions(parser): ...@@ -26,8 +26,7 @@ def AddResultsOptions(parser):
group.add_option('--chartjson', action='store_true', group.add_option('--chartjson', action='store_true',
help='Output Chart JSON. Ignores --output-format.') help='Output Chart JSON. Ignores --output-format.')
group.add_option('--output-format', action='append', dest='output_formats', group.add_option('--output-format', action='append', dest='output_formats',
default=[_OUTPUT_FORMAT_CHOICES[0]], choices=_OUTPUT_FORMAT_CHOICES, default=[],
choices=_OUTPUT_FORMAT_CHOICES,
help='Output format. Defaults to "%%default". ' help='Output format. Defaults to "%%default". '
'Can be %s.' % ', '.join(_OUTPUT_FORMAT_CHOICES)) 'Can be %s.' % ', '.join(_OUTPUT_FORMAT_CHOICES))
group.add_option('-o', '--output', group.add_option('-o', '--output',
...@@ -78,6 +77,9 @@ def CreateResults(benchmark_metadata, options): ...@@ -78,6 +77,9 @@ def CreateResults(benchmark_metadata, options):
Args: Args:
options: Contains the options specified in AddResultsOptions. options: Contains the options specified in AddResultsOptions.
""" """
if not options.output_formats:
options.output_formats = [_OUTPUT_FORMAT_CHOICES[0]]
# TODO(chrishenry): It doesn't make sense to have a single output_file flag # TODO(chrishenry): It doesn't make sense to have a single output_file flag
# with multiple output formatters. We should explore other possible options: # with multiple output formatters. We should explore other possible options:
# - Have an output_file per output formatter # - Have an output_file per output formatter
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment