From 16eaf334ac812f888d988f44ffdcf0da62f02afb Mon Sep 17 00:00:00 2001 From: Rd Date: Fri, 28 Jun 2024 21:21:05 +0530 Subject: [PATCH] Added org names to specifically pick the args to and make reordering possible --- .../oppia/android/scripts/coverage/RunCoverage.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt b/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt index 7be8539e7ac..cb034e78653 100644 --- a/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt +++ b/scripts/src/java/org/oppia/android/scripts/coverage/RunCoverage.kt @@ -33,11 +33,14 @@ import java.util.concurrent.TimeUnit fun main(vararg args: String) { val repoRoot = args[0] val filePath = args[1] - val format = args.getOrNull(2) - val reportFormat = when { - format.equals("HTML", ignoreCase = true) -> ReportFormat.HTML - format.equals("MARKDOWN", ignoreCase = true) || format == null -> ReportFormat.MARKDOWN - format.startsWith("processTimeout=") -> ReportFormat.MARKDOWN + + val format = args.find { it.startsWith("format=", ignoreCase = true) } + ?.substringAfter("=") + ?.uppercase() ?: "MARKDOWN" + + val reportFormat = when (format) { + "HTML" -> ReportFormat.HTML + "MARKDOWN" -> ReportFormat.MARKDOWN else -> throw IllegalArgumentException("Unsupported report format: $format") }