code_size_compare.py: classify arguments in parser
This commit splits parsed arguments into required group and optional group to present help message clearer to users. Signed-off-by: Yanray Wang <yanray.wang@arm.com>
This commit is contained in:
parent
c18cd89b71
commit
502c54f8c1
1 changed files with 19 additions and 27 deletions
|
@ -1,8 +1,6 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Purpose
|
|
||||||
|
|
||||||
This script is for comparing the size of the library files from two
|
This script is for comparing the size of the library files from two
|
||||||
different Git revisions within an Mbed TLS repository.
|
different Git revisions within an Mbed TLS repository.
|
||||||
The results of the comparison is formatted as csv and stored at a
|
The results of the comparison is formatted as csv and stored at a
|
||||||
|
@ -278,41 +276,35 @@ class CodeSizeComparison:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(description=(__doc__))
|
||||||
description=(
|
group_required = parser.add_argument_group(
|
||||||
"""This script is for comparing the size of the library files
|
'required arguments',
|
||||||
from two different Git revisions within an Mbed TLS repository.
|
'required arguments to parse for running ' + os.path.basename(__file__))
|
||||||
The results of the comparison is formatted as csv, and stored at
|
group_required.add_argument(
|
||||||
a configurable location.
|
"-o", "--old-rev", type=str, required=True,
|
||||||
Note: must be run from Mbed TLS root."""
|
help="old revision for comparison.")
|
||||||
)
|
|
||||||
)
|
group_optional = parser.add_argument_group(
|
||||||
parser.add_argument(
|
'optional arguments',
|
||||||
|
'optional arguments to parse for running ' + os.path.basename(__file__))
|
||||||
|
group_optional.add_argument(
|
||||||
"-r", "--result-dir", type=str, default="comparison",
|
"-r", "--result-dir", type=str, default="comparison",
|
||||||
help="directory where comparison result is stored, \
|
help="directory where comparison result is stored, \
|
||||||
default is comparison",
|
default is comparison")
|
||||||
)
|
group_optional.add_argument(
|
||||||
parser.add_argument(
|
|
||||||
"-o", "--old-rev", type=str, help="old revision for comparison.",
|
|
||||||
required=True,
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-n", "--new-rev", type=str, default=None,
|
"-n", "--new-rev", type=str, default=None,
|
||||||
help="new revision for comparison, default is the current work \
|
help="new revision for comparison, default is the current work \
|
||||||
directory, including uncommitted changes."
|
directory, including uncommitted changes.")
|
||||||
)
|
group_optional.add_argument(
|
||||||
parser.add_argument(
|
|
||||||
"-a", "--arch", type=str, default=detect_arch(),
|
"-a", "--arch", type=str, default=detect_arch(),
|
||||||
choices=list(map(lambda s: s.value, SupportedArch)),
|
choices=list(map(lambda s: s.value, SupportedArch)),
|
||||||
help="specify architecture for code size comparison, default is the\
|
help="specify architecture for code size comparison, default is the\
|
||||||
host architecture."
|
host architecture.")
|
||||||
)
|
group_optional.add_argument(
|
||||||
parser.add_argument(
|
|
||||||
"-c", "--config", type=str, default=SupportedConfig.DEFAULT.value,
|
"-c", "--config", type=str, default=SupportedConfig.DEFAULT.value,
|
||||||
choices=list(map(lambda s: s.value, SupportedConfig)),
|
choices=list(map(lambda s: s.value, SupportedConfig)),
|
||||||
help="specify configuration type for code size comparison,\
|
help="specify configuration type for code size comparison,\
|
||||||
default is the current MbedTLS configuration."
|
default is the current MbedTLS configuration.")
|
||||||
)
|
|
||||||
comp_args = parser.parse_args()
|
comp_args = parser.parse_args()
|
||||||
|
|
||||||
if os.path.isfile(comp_args.result_dir):
|
if os.path.isfile(comp_args.result_dir):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue