From c2fb540c67cf58642829c4ddffe74ea9badb7f35 Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Fri, 16 Sep 2022 17:03:54 +0100 Subject: [PATCH] Use a script specific description in CLI help Previous changes used the docstring of the test_generation module, which does not inform a user about the script. Signed-off-by: Werner Lewis --- scripts/mbedtls_dev/test_generation.py | 4 ++-- tests/scripts/generate_bignum_tests.py | 4 ++-- tests/scripts/generate_psa_tests.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/mbedtls_dev/test_generation.py b/scripts/mbedtls_dev/test_generation.py index a82f79e67..a88425f46 100644 --- a/scripts/mbedtls_dev/test_generation.py +++ b/scripts/mbedtls_dev/test_generation.py @@ -179,9 +179,9 @@ class TestGenerator: test_cases = self.targets[name](*target_args) self.write_test_data_file(name, test_cases) -def main(args, generator_class: Type[TestGenerator] = TestGenerator): +def main(args, description: str, generator_class: Type[TestGenerator] = TestGenerator): """Command line entry point.""" - parser = argparse.ArgumentParser(description=__doc__) + parser = argparse.ArgumentParser(description=description) parser.add_argument('--list', action='store_true', help='List available targets and exit') parser.add_argument('--list-for-cmake', action='store_true', diff --git a/tests/scripts/generate_bignum_tests.py b/tests/scripts/generate_bignum_tests.py index b4915d846..ceafa4a48 100755 --- a/tests/scripts/generate_bignum_tests.py +++ b/tests/scripts/generate_bignum_tests.py @@ -233,6 +233,6 @@ class BignumAdd(BignumOperation): def result(self) -> str: return quote_str("{:x}".format(self.int_a + self.int_b)) - if __name__ == '__main__': - test_generation.main(sys.argv[1:]) + # Use the section of the docstring relevant to the CLI as description + test_generation.main(sys.argv[1:], "\n".join(__doc__.splitlines()[:4])) diff --git a/tests/scripts/generate_psa_tests.py b/tests/scripts/generate_psa_tests.py index 81b35c9b3..c788fd76b 100755 --- a/tests/scripts/generate_psa_tests.py +++ b/tests/scripts/generate_psa_tests.py @@ -917,4 +917,4 @@ class PSATestGenerator(test_generation.TestGenerator): super().generate_target(name, self.info) if __name__ == '__main__': - test_generation.main(sys.argv[1:], PSATestGenerator) + test_generation.main(sys.argv[1:], __doc__, PSATestGenerator)