Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloox authored and mergify-bot committed May 4, 2021
1 parent 3bc3fc9 commit fb722ac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion test_runner/src/main/kotlin/ftl/domain/DescribeIosLocales.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ftl.api.fetchLocales
import ftl.args.IosArgs
import ftl.presentation.Output
import ftl.run.exception.FlankConfigurationError
import ftl.run.exception.FlankGeneralError
import java.nio.file.Paths

interface DescribeIosLocales : Output {
Expand All @@ -18,5 +19,5 @@ fun DescribeIosLocales.invoke() {

fetchLocales(Identity(IosArgs.loadOrDefault(Paths.get(configPath)).project, Platform.IOS, locale)).find {
it.id == locale
}?.out()
}?.out() ?: throw FlankGeneralError("ERROR: '$locale' is not a valid locale")
}
6 changes: 3 additions & 3 deletions test_runner/src/main/kotlin/ftl/environment/ListLocales.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ private const val NAME = "NAME"
private const val REGION = "REGION"

fun List<Locale>.getLocaleDescription(localeId: String) =
findLocales(localeId)?.prepareDescription(localeId).orErrorMessage(localeId).plus("\n")
findLocales(localeId)?.prepareDescription().orErrorMessage(localeId).plus("\n")

private fun List<Locale>.findLocales(localeId: String) = find { it.id == localeId }

fun Locale.prepareDescription(locale: String) = """
fun Locale.prepareDescription() = """
id: $id
name: $name
""".trimIndent().addRegionIfExist(region).addTagsIfExists(this).orErrorMessage(locale).plus("\n")
""".trimIndent().addRegionIfExist(region).addTagsIfExists(this)

private fun String.addRegionIfExist(region: String?) =
if (!region.isNullOrEmpty()) StringBuilder(this).appendLine("\nregion: $region").trim().toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class IosLocalesDescribeCommand :

override val out = outputLogger {
when (this) {
is Locale -> prepareDescription(locale)
is Locale -> prepareDescription()
else -> throwUnknownType()
}
}
Expand Down

0 comments on commit fb722ac

Please sign in to comment.