Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor: Android locales describes #1899

Merged
merged 1 commit into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}