From 3bc3fc941707b210e958e7577b346ba6e3c06f72 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 3 May 2021 10:31:03 +0200 Subject: [PATCH] modification --- .../src/main/kotlin/ftl/domain/DescribeIosLocales.kt | 4 +++- .../src/main/kotlin/ftl/environment/ListLocales.kt | 10 +++++----- .../ios/configuration/IosLocalesDescribeCommand.kt | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt b/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt index 0c0193a3b6..1d7b1d7d80 100644 --- a/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt +++ b/test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt @@ -16,5 +16,7 @@ interface DescribeIosLocales : Output { fun DescribeIosLocales.invoke() { if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.") - fetchLocales(Identity(IosArgs.loadOrDefault(Paths.get(configPath)).project, Platform.IOS, locale)).out() + fetchLocales(Identity(IosArgs.loadOrDefault(Paths.get(configPath)).project, Platform.IOS, locale)).find { + it.id == locale + }?.out() } diff --git a/test_runner/src/main/kotlin/ftl/environment/ListLocales.kt b/test_runner/src/main/kotlin/ftl/environment/ListLocales.kt index 3e146e8702..a4024f2032 100644 --- a/test_runner/src/main/kotlin/ftl/environment/ListLocales.kt +++ b/test_runner/src/main/kotlin/ftl/environment/ListLocales.kt @@ -29,14 +29,14 @@ private const val NAME = "NAME" private const val REGION = "REGION" fun List.getLocaleDescription(localeId: String) = - findLocales(localeId)?.prepareDescription().orErrorMessage(localeId).plus("\n") + findLocales(localeId)?.prepareDescription(localeId).orErrorMessage(localeId).plus("\n") private fun List.findLocales(localeId: String) = find { it.id == localeId } -private fun Locale.prepareDescription() = """ - id: $id - name: $name -""".trimIndent().addRegionIfExist(region).addTagsIfExists(this) +fun Locale.prepareDescription(locale: String) = """ +id: $id +name: $name +""".trimIndent().addRegionIfExist(region).addTagsIfExists(this).orErrorMessage(locale).plus("\n") private fun String.addRegionIfExist(region: String?) = if (!region.isNullOrEmpty()) StringBuilder(this).appendLine("\nregion: $region").trim().toString() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt index 65a899a0f8..a2baf72e43 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt @@ -4,7 +4,7 @@ import ftl.api.Locale import ftl.config.FtlConstants import ftl.domain.DescribeIosLocales import ftl.domain.invoke -import ftl.environment.getLocaleDescription +import ftl.environment.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType import picocli.CommandLine @@ -44,7 +44,7 @@ class IosLocalesDescribeCommand : override val out = outputLogger { when (this) { - is List<*> -> (this as List).getLocaleDescription(locale) + is Locale -> prepareDescription(locale) else -> throwUnknownType() } }