imgtool: Update version.py to take command line arguments

Main method printed hardcoded versions, update to take argument
to enable the possibility of testing version strings by invoking
the command through command line.

Signed-off-by: Rustam Ismayilov <rustam.ismayilov@arm.com>
Change-Id: If75769ef223944865313ed95336e859ebef85fd6
This commit is contained in:
Rustam Ismayilov 2023-12-13 15:38:59 +01:00 committed by Dávid Vincze
parent 316a139c1c
commit 533fef2ad7
1 changed files with 7 additions and 6 deletions

View File

@ -1,4 +1,5 @@
# Copyright 2017 Linaro Limited # Copyright 2017 Linaro Limited
# Copyright 2024 Arm Limited
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -20,9 +21,9 @@ Semi Semantic Versioning
Implements a subset of semantic versioning that is supportable by the image Implements a subset of semantic versioning that is supportable by the image
header. header.
""" """
from collections import namedtuple
import re import re
import sys
from collections import namedtuple
SemiSemVersion = namedtuple('SemiSemVersion', ['major', 'minor', 'revision', SemiSemVersion = namedtuple('SemiSemVersion', ['major', 'minor', 'revision',
'build']) 'build'])
@ -49,7 +50,7 @@ def decode_version(text):
if __name__ == '__main__': if __name__ == '__main__':
print(decode_version("1.2")) if len(sys.argv) > 1:
print(decode_version("1.0")) print(decode_version(sys.argv[1]))
print(decode_version("0.0.2+75")) else:
print(decode_version("0.0.0+00")) print("Requires an argument, e.g. '1.0.0'")