-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] adding quiet option for welcome in tagger cli, for calculate-…
…version usability
- Loading branch information
1 parent
275d785
commit b739b10
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
9 changes: 8 additions & 1 deletion
9
tools/tagger-cli/src/commonMain/kotlin/com/zegreatrob/tools/tagger/cli/Welcome.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 |
---|---|---|
@@ -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.") | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
tools/tagger-cli/src/jvmTest/kotlin/com/zegreatrob/tools/tagger/cli/WelcomeTest.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,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) | ||
} | ||
} | ||
} |