Skip to content

Commit 050571e

Browse files
committed
Updates to display version with --version option
1 parent 010720d commit 050571e

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

VERSION.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-07-07-b105c9d

vcast_exec.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@ class CITool(Enum):
6464
BAMBOO = "Bamboo"
6565
UNKNOWN = "Unknown CI/CD"
6666

67+
def displayVersion():
68+
versionInfo = "Version Unknown"
69+
70+
# Get absolute path to directory containing the current script
71+
script_dir = os.path.dirname(os.path.abspath(__file__))
72+
73+
# Build path to VERSION.txt
74+
version_path = os.path.join(script_dir, 'VERSION.txt')
75+
76+
if os.path.exists(version_path):
77+
with open(version_path,"r") as fd:
78+
versionInfo = fd.read()
79+
print("vc_scripts_submodule Version: ", versionInfo)
80+
6781
class VectorCASTExecute(object):
6882

6983
def detect_ci_tool(self):
@@ -436,7 +450,7 @@ def runExec(self):
436450
if __name__ == '__main__':
437451

438452
parser = argparse.ArgumentParser()
439-
parser.add_argument('ManageProject', help='VectorCAST Project Name')
453+
parser.add_argument('ManageProject', nargs='?', help='VectorCAST Project Name')
440454

441455
actionGroup = parser.add_argument_group('Script Actions', 'Options for the main tasks')
442456
actionGroup.add_argument('--build-execute', help='Builds and exeuctes the VectorCAST Project', action="store_true", default = False)
@@ -481,20 +495,29 @@ def runExec(self):
481495
actionGroup.add_argument('--print_exc', help='Prints exceptions', action="store_true", default = False)
482496
actionGroup.add_argument('--timing', help='Prints timing information for metrics generation', action="store_true", default = False)
483497
actionGroup.add_argument('-v', '--verbose', help='Enable verbose output', action="store_true", default = False)
484-
498+
actionGroup.add_argument('--version', help='Displays the version information', action="store_true", default = False)
485499

486500
args = parser.parse_args()
487501

488-
if args.ci:
489-
os.environ['VCAST_USE_CI_LICENSES'] = "1"
490-
491-
os.environ['VCAST_MANAGE_PROJECT_DIRECTORY'] = os.path.abspath(args.ManageProject).rsplit(".",1)[0]
502+
# Conditional requirement check
503+
if not args.version and not args.ManageProject:
504+
parser.error("ManageProject is required unless --version is specified")
505+
sys.exit(0)
492506

493-
if not os.path.isfile(args.ManageProject):
507+
if args.ManageProject and not os.path.isfile(args.ManageProject):
494508
print ("Manage project (.vcm file) provided does not exist: " + args.ManageProject)
495509
print ("exiting...")
496510
sys.exit(-1)
497511

512+
if args.version:
513+
displayVersion()
514+
sys.exit(0)
515+
516+
if args.ci:
517+
os.environ['VCAST_USE_CI_LICENSES'] = "1"
518+
519+
os.environ['VCAST_MANAGE_PROJECT_DIRECTORY'] = os.path.abspath(args.ManageProject).rsplit(".",1)[0]
520+
498521
vcExec = VectorCASTExecute(args)
499522

500523
if args.build_execute or args.build:
@@ -526,6 +549,7 @@ def runExec(self):
526549

527550
if args.export_rgw:
528551
vcExec.exportRgw()
552+
529553
if vcExec.useJunitFailCountPct:
530554
print("--exit_with_failed_count=" + args.exit_with_failed_count + " specified. Fail Percent = " + str(round(vcExec.failed_pct,0)) + "% Return code: ", str(vcExec.failed_count))
531555
sys.exit(vcExec.failed_count)

0 commit comments

Comments
 (0)