Skip to content

Commit

Permalink
Iteration 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloox authored and mergify-bot committed May 6, 2021
1 parent 82a0817 commit f2eebd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test_runner/src/main/kotlin/ftl/domain/DescribeAndroidLocales.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
package ftl.domain

import flank.common.log
import ftl.api.Locale
import ftl.api.Locale.Identity
import ftl.api.Platform
import ftl.api.fetchLocales
import ftl.args.AndroidArgs
import ftl.presentation.cli.firebase.test.locale.getLocaleDescription
import ftl.presentation.Output
import ftl.run.exception.FlankConfigurationError
import ftl.run.exception.FlankGeneralError
import java.nio.file.Paths

interface DescribeAndroidLocales {
interface DescribeAndroidLocales : Output {
val locale: String
val configPath: String
}

fun DescribeAndroidLocales.invoke() {
if (locale.isBlank()) throw FlankConfigurationError("Argument LOCALE must be specified.")
log(
fetchLocales(
Locale.Identity(
AndroidArgs.loadOrDefault(Paths.get(configPath)).project,
Platform.ANDROID
)
).getLocaleDescription(locale)
)

fetchLocales(Identity(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, Platform.ANDROID)).find {
it.id == locale
}?.out() ?: throw FlankGeneralError("ERROR: '$locale' is not a valid locale")
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package ftl.presentation.cli.firebase.test.android.locales

import ftl.api.Locale
import ftl.config.FtlConstants
import ftl.domain.DescribeAndroidLocales
import ftl.domain.invoke
import ftl.presentation.cli.firebase.test.locale.prepareDescription
import ftl.presentation.outputLogger
import ftl.presentation.throwUnknownType
import picocli.CommandLine

@CommandLine.Command(
Expand Down Expand Up @@ -37,5 +41,12 @@ class AndroidLocalesDescribeCommand :
)
override var configPath: String = FtlConstants.defaultAndroidConfig

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

override fun run() = invoke()
}

0 comments on commit f2eebd9

Please sign in to comment.