diff --git a/tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Welcome.kt b/tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Welcome.kt index a931250..53c7b88 100644 --- a/tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Welcome.kt +++ b/tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Welcome.kt @@ -1,10 +1,17 @@ package com.zegreatrob.tools.tagger.cli import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.flag +import com.github.ajalt.clikt.parameters.options.option class Welcome : CliktCommand() { + private val quiet by option("--quiet", "-q") + .flag(default = false) + override fun run() { - echo("Welcome to Tagger CLI.") + if (!quiet) { + echo("Welcome to Tagger CLI.") + } } } diff --git a/tools/tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/WelcomeTest.kt b/tools/tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/WelcomeTest.kt new file mode 100644 index 0000000..6c45643 --- /dev/null +++ b/tools/tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/WelcomeTest.kt @@ -0,0 +1,27 @@ +package com.zegreatrob.tools.tagger.cli + +import com.github.ajalt.clikt.testing.test +import kotlin.test.Test +import kotlin.test.assertEquals + +class WelcomeTest { + @Test + fun quietWillSuppressWelcome() { + Welcome() + .test("--quiet") + .output + .let { + assertEquals("", it) + } + } + + @Test + fun quietHasShorthand() { + Welcome() + .test("-q") + .output + .let { + assertEquals("", it) + } + } +}