Skip to content

Commit

Permalink
refactor: list android locales (#1894)
Browse files Browse the repository at this point in the history
Fixes #1854 

## Test Plan
> How do we know the code works?
Unit tests pass & refactored inline with #1854 

## Checklist

- [x] Unit tested
  • Loading branch information
Sloox authored May 5, 2021
1 parent 6eaee7a commit 944fa26
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 3 additions & 6 deletions test_runner/src/main/kotlin/ftl/domain/ListAndroidLocales.kt
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package ftl.domain

import flank.common.logLn
import ftl.api.Locale.Identity
import ftl.api.Platform
import ftl.api.fetchLocales
import ftl.args.AndroidArgs
import ftl.environment.toCliTable
import ftl.presentation.Output
import java.nio.file.Paths

interface ListAndroidLocales {
interface ListAndroidLocales : Output {
val configPath: String
}

operator fun ListAndroidLocales.invoke() {
logLn(
fetchLocales(Identity(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, Platform.ANDROID)).toCliTable()
)
fetchLocales(Identity(AndroidArgs.loadOrDefault(Paths.get(configPath)).project, Platform.ANDROID)).out()
}
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.ListAndroidLocales
import ftl.domain.invoke
import ftl.environment.toCliTable
import ftl.presentation.outputLogger
import ftl.presentation.throwUnknownType
import picocli.CommandLine

@CommandLine.Command(
Expand All @@ -26,6 +30,14 @@ class AndroidLocalesListCommand :
)
override var configPath: String = FtlConstants.defaultAndroidConfig

override val out = outputLogger {
@Suppress("UNCHECKED_CAST")
when (this) {
is List<*> -> (this as List<Locale>).toCliTable()
else -> throwUnknownType()
}
}

@CommandLine.Option(
names = ["-h", "--help"],
usageHelp = true,
Expand Down

0 comments on commit 944fa26

Please # to comment.