-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#884 added printing available locales for iOS devices
- Loading branch information
Piotr Adamczyk
committed
Jul 21, 2020
1 parent
bc7097d
commit 2a659eb
Showing
12 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package ftl.cli.firebase.test.ios.configuration | ||
|
||
import picocli.CommandLine | ||
|
||
@CommandLine.Command( | ||
name = "locales", | ||
headerHeading = "", | ||
synopsisHeading = "%n", | ||
descriptionHeading = "%n@|bold,underline Description:|@%n%n", | ||
parameterListHeading = "%n@|bold,underline Parameters:|@%n", | ||
optionListHeading = "%n@|bold,underline Options:|@%n", | ||
header = ["Information about available locales on device"], | ||
description = ["Information about available locales on device. For example prints list of available locales to test against"], | ||
subcommands = [IosLocalesListCommand::class], | ||
usageHelpAutoWidth = true | ||
) | ||
class IosLocalesCommand : Runnable { | ||
override fun run() { | ||
CommandLine.usage(IosLocalesCommand(), System.out) | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package ftl.cli.firebase.test.ios.configuration | ||
|
||
import ftl.args.IosArgs | ||
import ftl.config.FtlConstants | ||
import ftl.ios.IosCatalog.localesAsTable | ||
import picocli.CommandLine | ||
import java.nio.file.Paths | ||
|
||
@CommandLine.Command( | ||
name = "list", | ||
headerHeading = "", | ||
synopsisHeading = "%n", | ||
descriptionHeading = "%n@|bold,underline Description:|@%n%n", | ||
parameterListHeading = "%n@|bold,underline Parameters:|@%n", | ||
optionListHeading = "%n@|bold,underline Options:|@%n", | ||
header = ["Print current list of locales available to test against"], | ||
description = ["Print current list of iOS locales available to test against"], | ||
usageHelpAutoWidth = true | ||
) | ||
class IosLocalesListCommand : Runnable { | ||
override fun run() { | ||
println(localesAsTable(projectId = IosArgs.load(Paths.get(configPath)).project)) | ||
} | ||
|
||
@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"]) | ||
var configPath: String = FtlConstants.defaultIosConfig | ||
|
||
@CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"]) | ||
var usageHelpRequested: Boolean = false | ||
} |
28 changes: 28 additions & 0 deletions
28
test_runner/src/main/kotlin/ftl/environment/ListLocales.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ftl.environment | ||
|
||
import com.google.api.services.testing.model.Locale | ||
import ftl.util.applyColorsUsing | ||
import ftl.util.buildTable | ||
|
||
fun List<Locale>.asPrintableTable() = createTestEnvironment().createLocalesTable() | ||
|
||
private fun List<Locale>.createTestEnvironment() = | ||
fold(mutableMapOf<String, MutableList<String>>()) { allLocales, locale -> | ||
allLocales.apply { | ||
getOrCreateList(LOCALE).add(locale.id.orEmpty()) | ||
getOrCreateList(NAME).add(locale.name.orEmpty()) | ||
getOrCreateList(REGION).add(locale.region.orEmpty()) | ||
getOrCreateList(TAGS).add(locale.tags?.joinToString().orEmpty()) | ||
} | ||
} | ||
|
||
private fun TestEnvironmentInfo.createLocalesTable() = buildTable( | ||
createTableColumnFor(LOCALE), | ||
createTableColumnFor(NAME), | ||
createTableColumnFor(REGION), | ||
createTableColumnFor(TAGS).applyColorsUsing(tagToSystemOutColorMapper) | ||
) | ||
|
||
private const val LOCALE = "LOCALE" | ||
private const val NAME = "NAME" | ||
private const val REGION = "REGION" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...nner/src/test/kotlin/ftl/cli/firebase/test/ios/configuration/IosLocalesListCommandTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ftl.cli.firebase.test.ios.configuration | ||
|
||
import com.google.common.truth.Truth | ||
import org.junit.Test | ||
import picocli.CommandLine | ||
|
||
class IosLocalesListCommandTest { | ||
|
||
@Test | ||
fun androidLocalesListCommandShouldParseConfig() { | ||
val cmd = IosLocalesListCommand() | ||
CommandLine(cmd).parseArgs("--config=a") | ||
|
||
Truth.assertThat(cmd.configPath).isEqualTo("a") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters