diff --git a/corellium/cli/src/main/kotlin/flank/corellium/cli/RunTestCorelliumAndroidCommand.kt b/corellium/cli/src/main/kotlin/flank/corellium/cli/RunTestCorelliumAndroidCommand.kt index 69bfd4db84..3f1e215623 100644 --- a/corellium/cli/src/main/kotlin/flank/corellium/cli/RunTestCorelliumAndroidCommand.kt +++ b/corellium/cli/src/main/kotlin/flank/corellium/cli/RunTestCorelliumAndroidCommand.kt @@ -50,6 +50,13 @@ class RunTestCorelliumAndroidCommand : ) var project: String? by data + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) + var usageHelpRequested: Boolean = false + @CommandLine.Option( names = ["--apks"], split = ";", diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/AuthCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/AuthCommand.kt index 4dab99c334..755e744619 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/AuthCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/AuthCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli import ftl.presentation.cli.auth.LoginCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -13,4 +13,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class AuthCommand : PrintHelp +class AuthCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/CorelliumCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/CorelliumCommand.kt index 72911b7a84..3fad5d10f9 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/CorelliumCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/CorelliumCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli import ftl.presentation.cli.corellium.TestCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -12,4 +12,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class CorelliumCommand : PrintHelp +class CorelliumCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/FirebaseCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/FirebaseCommand.kt index 6bfc81e463..2471fae542 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/FirebaseCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/FirebaseCommand.kt @@ -3,7 +3,7 @@ package ftl.presentation.cli import ftl.presentation.cli.firebase.CancelCommand import ftl.presentation.cli.firebase.RefreshCommand import ftl.presentation.cli.firebase.TestCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -16,4 +16,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class FirebaseCommand : PrintHelp +class FirebaseCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/MainCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/MainCommand.kt index e7acf9df47..2ea07872aa 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/MainCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/MainCommand.kt @@ -8,6 +8,7 @@ import ftl.presentation.cli.firebase.test.IPBlocksCommand import ftl.presentation.cli.firebase.test.IosCommand import ftl.presentation.cli.firebase.test.NetworkProfilesCommand import ftl.presentation.cli.firebase.test.ProvidedSoftwareCommand +import ftl.util.PrintHelpCommand import ftl.util.printVersionInfo import picocli.CommandLine @@ -27,7 +28,7 @@ import picocli.CommandLine IPBlocksCommand::class ] ) -class MainCommand : Runnable { +class MainCommand : PrintHelpCommand() { @CommandLine.Option( names = ["-v", "--version"], diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/auth/LoginCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/auth/LoginCommand.kt index 51fb7f1443..ce220380ea 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/auth/LoginCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/auth/LoginCommand.kt @@ -2,6 +2,7 @@ package ftl.presentation.cli.auth import ftl.domain.LoginGoogleAccount import ftl.domain.invoke +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,15 +18,8 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class LoginCommand : - Runnable, + PrintHelpCommand(), LoginGoogleAccount { - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/TestCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/TestCommand.kt index f4ad3c69f7..3beb82a41f 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/TestCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/TestCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.corellium import ftl.presentation.cli.corellium.test.AndroidCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -12,4 +12,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class TestCommand : PrintHelp +class TestCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/test/AndroidCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/test/AndroidCommand.kt index c83bb81c0f..89f6ee3988 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/test/AndroidCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/corellium/test/AndroidCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.corellium.test import flank.corellium.cli.RunTestCorelliumAndroidCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -12,4 +12,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class AndroidCommand : PrintHelp +class AndroidCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/CancelCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/CancelCommand.kt index 094eddb858..b1f14f36b5 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/CancelCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/CancelCommand.kt @@ -5,6 +5,7 @@ import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType import ftl.run.MatrixCancelStatus +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -24,16 +25,9 @@ Reads in the matrix_ids.json file. Cancels any incomplete matrices. usageHelpAutoWidth = true ) class CancelCommand : - Runnable, + PrintHelpCommand(), CancelLastRun { - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/RefreshCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/RefreshCommand.kt index 43c5d97266..851eddc70b 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/RefreshCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/RefreshCommand.kt @@ -2,9 +2,9 @@ package ftl.presentation.cli.firebase import ftl.domain.RefreshLastRun import ftl.domain.invoke +import ftl.util.PrintHelpCommand import kotlinx.coroutines.runBlocking import picocli.CommandLine.Command -import picocli.CommandLine.Option @Command( name = "refresh", @@ -23,15 +23,8 @@ Reads in the matrix_ids.json file. Refreshes any incomplete matrices. usageHelpAutoWidth = true ) class RefreshCommand : - Runnable, + PrintHelpCommand(), RefreshLastRun { - @Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = runBlocking { invoke() } } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/TestCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/TestCommand.kt index 382acc1f87..7326cd0ac8 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/TestCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/TestCommand.kt @@ -5,7 +5,7 @@ import ftl.presentation.cli.firebase.test.IPBlocksCommand import ftl.presentation.cli.firebase.test.IosCommand import ftl.presentation.cli.firebase.test.NetworkProfilesCommand import ftl.presentation.cli.firebase.test.ProvidedSoftwareCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -20,4 +20,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class TestCommand : PrintHelp +class TestCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/AndroidCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/AndroidCommand.kt index 494009b8c2..8be82cd316 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/AndroidCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/AndroidCommand.kt @@ -7,7 +7,7 @@ import ftl.presentation.cli.firebase.test.android.AndroidOrientationsCommand import ftl.presentation.cli.firebase.test.android.AndroidRunCommand import ftl.presentation.cli.firebase.test.android.AndroidTestEnvironmentCommand import ftl.presentation.cli.firebase.test.android.AndroidVersionsCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -24,4 +24,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class AndroidCommand : PrintHelp +class AndroidCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/CommonRunCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/CommonRunCommand.kt index 52f82be622..93fff8670d 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/CommonRunCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/CommonRunCommand.kt @@ -6,9 +6,10 @@ import ftl.config.asDevice import ftl.config.common.CommonFlankConfig import ftl.config.common.CommonGcloudConfig import ftl.config.common.addDevice +import ftl.util.PrintHelpCommand import picocli.CommandLine -abstract class CommonRunCommand : Runnable { +abstract class CommonRunCommand : PrintHelpCommand() { @CommandLine.Mixin private val commonGcloudConfig = CommonGcloudConfig() @@ -23,13 +24,6 @@ abstract class CommonRunCommand : Runnable { abstract val config: Config.Platform<*, *> - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - // Gcloud @CommandLine.Option( names = ["--device"], diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IPBlocksCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IPBlocksCommand.kt index a48392a8b3..9e65681b02 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IPBlocksCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IPBlocksCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.firebase.test import ftl.presentation.cli.firebase.test.ipblocks.IPBlocksListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -11,4 +11,4 @@ import picocli.CommandLine header = ["Explore IP blocks used by Firebase Test Lab devices."], usageHelpAutoWidth = true ) -class IPBlocksCommand : PrintHelp +class IPBlocksCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IosCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IosCommand.kt index 3e8a00059e..1c8ecd42ce 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IosCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/IosCommand.kt @@ -7,7 +7,7 @@ import ftl.presentation.cli.firebase.test.ios.IosOrientationsCommand import ftl.presentation.cli.firebase.test.ios.IosRunCommand import ftl.presentation.cli.firebase.test.ios.IosTestEnvironmentCommand import ftl.presentation.cli.firebase.test.ios.IosVersionsCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command @Command( @@ -24,4 +24,4 @@ import picocli.CommandLine.Command ], usageHelpAutoWidth = true ) -class IosCommand : PrintHelp +class IosCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/NetworkProfilesCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/NetworkProfilesCommand.kt index 1958fbbe68..39b71823e5 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/NetworkProfilesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/NetworkProfilesCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test import ftl.presentation.cli.firebase.test.networkprofiles.NetworkProfilesDescribeCommand import ftl.presentation.cli.firebase.test.networkprofiles.NetworkProfilesListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -15,4 +15,4 @@ import picocli.CommandLine header = ["Explore network profiles available for testing."], usageHelpAutoWidth = true ) -class NetworkProfilesCommand : PrintHelp +class NetworkProfilesCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ProvidedSoftwareCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ProvidedSoftwareCommand.kt index bb59c28f27..3b52e3263c 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ProvidedSoftwareCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ProvidedSoftwareCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.firebase.test import ftl.presentation.cli.firebase.test.providedsoftware.ProvidedSoftwareListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -12,4 +12,4 @@ import picocli.CommandLine ], usageHelpAutoWidth = true ) -class ProvidedSoftwareCommand : PrintHelp +class ProvidedSoftwareCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidDoctorCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidDoctorCommand.kt index fd349de054..0fc73ca728 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidDoctorCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidDoctorCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.summary import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command import picocli.CommandLine.Option @@ -26,16 +27,9 @@ import picocli.CommandLine.Option usageHelpAutoWidth = true ) class AndroidDoctorCommand : - Runnable, + PrintHelpCommand(), RunDoctor { - @Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - @Option( names = ["-c", "--config"], description = ["YAML config file path"] diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidLocalesCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidLocalesCommand.kt index f40bf45f87..aebc768490 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidLocalesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidLocalesCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.android import ftl.presentation.cli.firebase.test.android.locales.AndroidLocalesDescribeCommand import ftl.presentation.cli.firebase.test.android.locales.AndroidLocalesListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine subcommands = [AndroidLocalesListCommand::class, AndroidLocalesDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidLocalesCommand : PrintHelp +class AndroidLocalesCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidModelsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidModelsCommand.kt index ed57414148..ec1e7a06c7 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidModelsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidModelsCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.android import ftl.presentation.cli.firebase.test.android.models.AndroidModelDescribeCommand import ftl.presentation.cli.firebase.test.android.models.AndroidModelsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine subcommands = [AndroidModelsListCommand::class, AndroidModelDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidModelsCommand : PrintHelp +class AndroidModelsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidOrientationsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidOrientationsCommand.kt index 94818daeaf..82edbd35ad 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidOrientationsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidOrientationsCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.firebase.test.android import ftl.presentation.cli.firebase.test.android.orientations.AndroidOrientationsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -16,4 +16,4 @@ import picocli.CommandLine subcommands = [AndroidOrientationsListCommand::class], usageHelpAutoWidth = true ) -class AndroidOrientationsCommand : PrintHelp +class AndroidOrientationsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt index bdf113a884..55ed56890f 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidTestEnvironmentCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.environment.prepareOutputString import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -27,7 +28,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidTestEnvironmentCommand : - Runnable, + PrintHelpCommand(), DescribeAndroidTestEnvironment { @CommandLine.Option( @@ -36,13 +37,6 @@ class AndroidTestEnvironmentCommand : ) override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidVersionsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidVersionsCommand.kt index 849dbb2fa9..c35d363536 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidVersionsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/AndroidVersionsCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.android import ftl.presentation.cli.firebase.test.android.versions.AndroidVersionsDescribeCommand import ftl.presentation.cli.firebase.test.android.versions.AndroidVersionsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine subcommands = [AndroidVersionsListCommand::class, AndroidVersionsDescribeCommand::class], usageHelpAutoWidth = true ) -class AndroidVersionsCommand : PrintHelp +class AndroidVersionsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesDescribeCommand.kt index ab0ec369b4..4a291e9fb9 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.locale.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -20,7 +21,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidLocalesDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeAndroidLocales { @CommandLine.Parameters( diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesListCommand.kt index ef13ec2aaa..10ee130697 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/locales/AndroidLocalesListCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.locale.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asListOrNull import picocli.CommandLine @@ -22,7 +23,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidLocalesListCommand : - Runnable, + PrintHelpCommand(), ListAndroidLocales { @CommandLine.Option( @@ -31,13 +32,6 @@ class AndroidLocalesListCommand : ) override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt index bc27366f2a..26389a1bf3 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.android.models.describe.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -20,16 +21,9 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidModelDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeAndroidModels { - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - @CommandLine.Option( names = ["-c", "--config"], description = ["YAML config file path"] diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelsListCommand.kt index 4af9a28831..648e0d6fe9 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/models/AndroidModelsListCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.environment.android.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidModelsListCommand : - Runnable, + PrintHelpCommand(), ListAndroidModels { @CommandLine.Option( @@ -36,12 +37,5 @@ class AndroidModelsListCommand : } } - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt index 684ed99753..b3998c004b 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/orientations/AndroidOrientationsListCommand.kt @@ -6,6 +6,7 @@ import ftl.domain.ListAndroidOrientations import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asListOrNull import picocli.CommandLine @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidOrientationsListCommand : - Runnable, + PrintHelpCommand(), ListAndroidOrientations { @CommandLine.Option( @@ -30,13 +31,6 @@ class AndroidOrientationsListCommand : ) override var configPath: String = FtlConstants.defaultAndroidConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt index fd6187bf48..8d6c2d6d39 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.environment.android.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidVersionsDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeAndroidVersions { @CommandLine.Option( diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt index c4c8eadef3..637412bccd 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/android/versions/AndroidVersionsListCommand.kt @@ -6,6 +6,7 @@ import ftl.domain.ListAndroidVersions import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asListOrNull import picocli.CommandLine @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class AndroidVersionsListCommand : - Runnable, + PrintHelpCommand(), ListAndroidVersions { @CommandLine.Option( @@ -34,12 +35,5 @@ class AndroidVersionsListCommand : asListOrNull()?.toCliTable() ?: throwUnknownType() } - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosDoctorCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosDoctorCommand.kt index d767fe7c91..776dccbc54 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosDoctorCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosDoctorCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.summary import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine.Command import picocli.CommandLine.Option @@ -26,16 +27,9 @@ import picocli.CommandLine.Option usageHelpAutoWidth = true ) class IosDoctorCommand : - Runnable, + PrintHelpCommand(), RunDoctor { - @Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - @Option( names = ["-c", "--config"], description = ["YAML config file path"] diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosLocalesCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosLocalesCommand.kt index 738007a718..90d81002bb 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosLocalesCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosLocalesCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.ios import ftl.presentation.cli.firebase.test.ios.configuration.IosLocalesDescribeCommand import ftl.presentation.cli.firebase.test.ios.configuration.IosLocalesListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine subcommands = [IosLocalesListCommand::class, IosLocalesDescribeCommand::class], usageHelpAutoWidth = true ) -class IosLocalesCommand : PrintHelp +class IosLocalesCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosModelsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosModelsCommand.kt index 44af7600f8..c40d712b89 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosModelsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosModelsCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.ios import ftl.presentation.cli.firebase.test.ios.models.IosModelDescribeCommand import ftl.presentation.cli.firebase.test.ios.models.IosModelsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine subcommands = [IosModelsListCommand::class, IosModelDescribeCommand::class], usageHelpAutoWidth = true ) -class IosModelsCommand : PrintHelp +class IosModelsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosOrientationsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosOrientationsCommand.kt index 2afdc4f316..dc5ac89d00 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosOrientationsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosOrientationsCommand.kt @@ -1,7 +1,7 @@ package ftl.presentation.cli.firebase.test.ios import ftl.presentation.cli.firebase.test.ios.orientations.IosOrientationsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -16,4 +16,4 @@ import picocli.CommandLine subcommands = [IosOrientationsListCommand::class], usageHelpAutoWidth = true ) -class IosOrientationsCommand : PrintHelp +class IosOrientationsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosTestEnvironmentCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosTestEnvironmentCommand.kt index 16d55450c8..aef1ad9a8a 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosTestEnvironmentCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosTestEnvironmentCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.environment.prepareOutputString import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -27,7 +28,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosTestEnvironmentCommand : - Runnable, + PrintHelpCommand(), DescribeIosTestEnvironment { @CommandLine.Option( @@ -36,13 +37,6 @@ class IosTestEnvironmentCommand : ) override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosVersionsCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosVersionsCommand.kt index c758549b82..01423d0a0c 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosVersionsCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/IosVersionsCommand.kt @@ -2,7 +2,7 @@ package ftl.presentation.cli.firebase.test.ios import ftl.presentation.cli.firebase.test.ios.versions.IosVersionsDescribeCommand import ftl.presentation.cli.firebase.test.ios.versions.IosVersionsListCommand -import ftl.util.PrintHelp +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -17,4 +17,4 @@ import picocli.CommandLine description = ["Information about available software versions. For example prints list of available software versions"], usageHelpAutoWidth = true ) -class IosVersionsCommand : PrintHelp +class IosVersionsCommand : PrintHelpCommand() diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt index 92f15e2bb3..5e8e14f0db 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.locale.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -20,7 +21,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosLocalesDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeIosLocales { @CommandLine.Parameters( diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt index c7d0891e95..f0433b11d2 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/configuration/IosLocalesListCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.locale.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asListOrNull import picocli.CommandLine @@ -22,7 +23,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosLocalesListCommand : - Runnable, + PrintHelpCommand(), ListIosLocales { @CommandLine.Option( @@ -31,13 +32,6 @@ class IosLocalesListCommand : ) override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelDescribeCommand.kt index e82c5c6337..b0c72af087 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.ios.models.describe.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -20,7 +21,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosModelDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeIosModels { @CommandLine.Option( @@ -41,13 +42,6 @@ class IosModelDescribeCommand : ) override var modelId: String = "" - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelsListCommand.kt index 0ca40da1dd..41cf27672a 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/models/IosModelsListCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.environment.ios.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosModelsListCommand : - Runnable, + PrintHelpCommand(), ListIosModels { @CommandLine.Option( @@ -37,12 +38,5 @@ class IosModelsListCommand : } } - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() } diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt index 4739eccabe..813929db97 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/orientations/IosOrientationsListCommand.kt @@ -5,9 +5,9 @@ import ftl.config.FtlConstants import ftl.domain.ListIosOrientations import ftl.domain.invoke import ftl.presentation.cli.firebase.test.android.orientations.toCliTable -import ftl.presentation.cli.firebase.test.locale.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asListOrNull import picocli.CommandLine @@ -23,7 +23,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosOrientationsListCommand : - Runnable, + PrintHelpCommand(), ListIosOrientations { @CommandLine.Option( @@ -32,13 +32,6 @@ class IosOrientationsListCommand : ) override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt index ed47aec83c..6d8a2ac6c9 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsDescribeCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.presentation.cli.firebase.test.ios.models.describe.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosVersionsDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeIosVersions { @CommandLine.Option( diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsListCommand.kt index b5d03ce309..9d144961aa 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ios/versions/IosVersionsListCommand.kt @@ -7,6 +7,7 @@ import ftl.domain.invoke import ftl.environment.ios.toCliTable import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -21,7 +22,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IosVersionsListCommand : - Runnable, + PrintHelpCommand(), ListIosVersions { @CommandLine.Option( @@ -30,13 +31,6 @@ class IosVersionsListCommand : ) override var configPath: String = FtlConstants.defaultIosConfig - @CommandLine.Option( - names = ["-h", "--help"], - usageHelp = true, - description = ["Prints this help message"] - ) - var usageHelpRequested: Boolean = false - override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ipblocks/IPBlocksListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ipblocks/IPBlocksListCommand.kt index 32cad3b969..294a19983a 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ipblocks/IPBlocksListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/ipblocks/IPBlocksListCommand.kt @@ -5,6 +5,7 @@ import ftl.domain.ListIPBlocks import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -19,8 +20,9 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class IPBlocksListCommand : - Runnable, + PrintHelpCommand(), ListIPBlocks { + override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt index 34da80cd73..e28e8f8cfd 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesDescribeCommand.kt @@ -6,6 +6,7 @@ import ftl.domain.invoke import ftl.environment.prepareDescription import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -20,7 +21,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class NetworkProfilesDescribeCommand : - Runnable, + PrintHelpCommand(), DescribeNetworkProfiles { @CommandLine.Parameters( diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt index 07f65ffb2b..c7eade519a 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/networkprofiles/NetworkProfilesListCommand.kt @@ -5,6 +5,7 @@ import ftl.domain.ListNetworkProfiles import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import ftl.util.asList import ftl.util.asListOrNull import picocli.CommandLine @@ -21,8 +22,9 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class NetworkProfilesListCommand : - Runnable, + PrintHelpCommand(), ListNetworkProfiles { + override fun run() = invoke() override val out = outputLogger { diff --git a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt index 539fc2a30b..ed89c7a29b 100644 --- a/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt +++ b/test_runner/src/main/kotlin/ftl/presentation/cli/firebase/test/providedsoftware/ProvidedSoftwareListCommand.kt @@ -5,6 +5,7 @@ import ftl.domain.ListProvidedSoftware import ftl.domain.invoke import ftl.presentation.outputLogger import ftl.presentation.throwUnknownType +import ftl.util.PrintHelpCommand import picocli.CommandLine @CommandLine.Command( @@ -19,7 +20,7 @@ import picocli.CommandLine usageHelpAutoWidth = true ) class ProvidedSoftwareListCommand : - Runnable, + PrintHelpCommand(), ListProvidedSoftware { override fun run() = invoke() diff --git a/test_runner/src/main/kotlin/ftl/util/PrintHelp.kt b/test_runner/src/main/kotlin/ftl/util/PrintHelp.kt deleted file mode 100644 index bc4f1b02a0..0000000000 --- a/test_runner/src/main/kotlin/ftl/util/PrintHelp.kt +++ /dev/null @@ -1,9 +0,0 @@ -package ftl.util - -import picocli.CommandLine - -interface PrintHelp : Runnable { - override fun run() { - CommandLine.usage(this, System.out) - } -} diff --git a/test_runner/src/main/kotlin/ftl/util/PrintHelpCommand.kt b/test_runner/src/main/kotlin/ftl/util/PrintHelpCommand.kt new file mode 100644 index 0000000000..4461bb4108 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/util/PrintHelpCommand.kt @@ -0,0 +1,15 @@ +package ftl.util + +import picocli.CommandLine + +abstract class PrintHelpCommand : Runnable { + override fun run() { + CommandLine.usage(this, System.out) + } + @CommandLine.Option( + names = ["-h", "--help"], + usageHelp = true, + description = ["Prints this help message"] + ) + var usageHelpRequested: Boolean = false +} diff --git a/test_runner/src/test/kotlin/ftl/MainTest.kt b/test_runner/src/test/kotlin/ftl/MainTest.kt index 4133f01c2f..171905bdcf 100644 --- a/test_runner/src/test/kotlin/ftl/MainTest.kt +++ b/test_runner/src/test/kotlin/ftl/MainTest.kt @@ -32,8 +32,9 @@ class MainTest { private fun assertMainHelpStrings(output: String) { assertThat(output.normalizeLineEnding()).contains( "flank.jar\n" + - " [-v] [--debug] [COMMAND]\n" + + " [-hv] [--debug] [COMMAND]\n" + " --debug Enables debug logging\n" + + " -h, --help Prints this help message\n" + " -v, --version Prints the version\n" + "Commands:\n" + " firebase\n" + diff --git a/test_runner/src/test/kotlin/ftl/cli/AuthCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/AuthCommandTest.kt index fd54b565e8..3916d29754 100644 --- a/test_runner/src/test/kotlin/ftl/cli/AuthCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/AuthCommandTest.kt @@ -21,7 +21,8 @@ class AuthCommandTest { val output = systemOutRule.log.normalizeLineEnding() assertThat(output).startsWith( "Manage oauth2 credentials for Google Cloud\n\n" + - "auth [COMMAND]\n" + + "auth [-h] [COMMAND]\n" + + " -h, --help Prints this help message\n" + "Commands:\n" + " login" ) diff --git a/test_runner/src/test/kotlin/ftl/cli/CliTest.kt b/test_runner/src/test/kotlin/ftl/cli/CliTest.kt new file mode 100644 index 0000000000..e416ad4afb --- /dev/null +++ b/test_runner/src/test/kotlin/ftl/cli/CliTest.kt @@ -0,0 +1,33 @@ +package ftl.cli + +import ftl.presentation.cli.MainCommand +import org.junit.Test +import picocli.CommandLine + +class CliTest { + + @Test + fun `all commands should contain help flags`() { + val cmd = CommandLine(MainCommand()) + val allCommands = (cmd.subcommands.values.getAllSubCommands() + cmd) + val commandsWithoutHelpFlag = + allCommands + .getCommandWithoutHelp() + + assert(commandsWithoutHelpFlag.isEmpty()) { "Help flag not found in command: flank ${commandsWithoutHelpFlag.joinToString { it.getCommandPath() }}" } + } + + private fun CommandLine.getCommandPath(message: String = ""): String { + return if (parent != null) parent.getCommandPath("$commandName $message") + else message.trim() + } + + private fun Collection.getAllSubCommands(): Collection = + if (any()) (this + flatMap { it.subcommands.values }.getAllSubCommands()) + else this + + private fun Collection.getCommandWithoutHelp() = map { command -> + command to command.commandSpec.args().mapNotNull { arg -> arg as? CommandLine.Model.OptionSpec } + .any { arg -> arg.names().contains("-h") || arg.names().contains("--help") } + }.filter { (_, containsHelp) -> !containsHelp }.map { (command, _) -> command } +} diff --git a/test_runner/src/test/kotlin/ftl/cli/FirebaseCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/FirebaseCommandTest.kt index 79ccdcebb7..c8b8ae4ceb 100644 --- a/test_runner/src/test/kotlin/ftl/cli/FirebaseCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/FirebaseCommandTest.kt @@ -20,7 +20,8 @@ class FirebaseCommandTest { FirebaseCommand().run() val output = systemOutRule.log.normalizeLineEnding() assertThat(output).startsWith( - "firebase [COMMAND]\n" + + "firebase [-h] [COMMAND]\n" + + " -h, --help Prints this help message\n" + "Commands:\n" + " test\n" + " refresh Downloads results for the last Firebase Test Lab run\n" + diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/TestCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/TestCommandTest.kt index 2a91d1141c..43dc88ad40 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/TestCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/TestCommandTest.kt @@ -20,7 +20,8 @@ class TestCommandTest { TestCommand().run() val output = systemOutRule.log.normalizeLineEnding() assertThat(output).startsWith( - "test [COMMAND]\n" + + "test [-h] [COMMAND]\n" + + " -h, --help Prints this help message\n" + "Commands:\n" + " android\n" + " ios\n" diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/IPBlocksCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/IPBlocksCommandTest.kt index 76e8697bc5..bbe793d9ea 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/IPBlocksCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/IPBlocksCommandTest.kt @@ -17,7 +17,8 @@ class IPBlocksCommandTest { val expected = """ Explore IP blocks used by Firebase Test Lab devices. -ip-blocks [COMMAND] +ip-blocks [-h] [COMMAND] + -h, --help Prints this help message Commands: list List all IP address blocks used by Firebase Test Lab devices """.trimIndent() diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/NetworkProfilesCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/NetworkProfilesCommandTest.kt index 14fd20cd52..d03512b4ab 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/NetworkProfilesCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/NetworkProfilesCommandTest.kt @@ -19,7 +19,8 @@ class NetworkProfilesCommandTest { val expected = listOf( "Explore network profiles available for testing.", - "network-profiles [COMMAND]", + "network-profiles [-h] [COMMAND]", + " -h, --help Prints this help message", "Commands:", " list List all network profiles available for testing", " describe Describe a network profile",