Random Kotlin Goodies
See RELEASING.md for information on how to release versions.
enum class Features {
FeatureA, FeatureB, FeatureC
}
val features = EnumSetBuilder.build<Features> {
+Features.FeatureA + Features.FeatureC
}
fun buildList(init: ListBuilder<String>.() -> Unit) {
val list = init.build()
}
buildList {
+"element"
+existingList
}
val process = process("echo 'Hello World!'") { io ->
println("Process did output $io") // process the I/O of any process
}.start()
println(process.exitValue) // 0
println(process.logged(OUT)) // Hello World!
script {
shebang()
line("some command")
!"""
a \
multi-line \
command
"""
deleteOnCompletion()
comment("leave no trace")
}
println(process.ioLog)
Executing /some/where/koodies.process.bka.sh
file:///some/where/koodies.process.bka.sh // <- simply click on it in your IDE
starting to install
installing...
completed.
Docker.busybox("""
while true; do
echo "looping"
sleep 1
done
""").execute()
classPath("file.svg").copyTo(somewhere)
directory.copyRecursivelyTo(somewhere)
if (path.notExists()) path.withDirectoriesCreated().createFile()
Kaomojis.`(#-_-)o´・━・・━・━━・━☆`.random()
╭───────────────────────────────────────────────────╮
│ │
│ Done. All tests passed within 1.20s │
│ All test containers running in CONCURRENT mode. │
│ │
╰───────────────────────────────────────────────────╯
█ ▉ ▊ ▋ ▌ ▍ ▎ ▏ PILLARS ▏ ▎ ▍ ▌ ▋ ▊ ▉ █
-
Logger
logging { logLine { "lazy log message" } }
-
Fixture
HtmlFile.copyTo(Locations.Temp)
-
Time
Now.emoji
if(file.age > 3.minutes) ...
-
Unicode, Code Points & Graphemes
Named Characters and Dictionary
Unicode.BoxDrawings.asTable()
─ BOX DRAWINGS LIGHT HORIZONTAL ━ BOX DRAWINGS HEAVY HORIZONTAL │ BOX DRAWINGS LIGHT VERTICAL ┃ BOX DRAWINGS HEAVY VERTICAL ...
Process Each Actual Character (and not each
char
)"aⒷ☷\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67".asCodePointSequence() -> "a", "Ⓑ", "☷", ":woman:" ZWJ, ":woman:", ZWJ, ":girl:", ZWJ, ":girl:"
Process Each Actual Grapheme (that is, what users perceive as a character)
"aⒷ☷\uD83D\uDC69\u200D\uD83D\uDC69\u200D\uD83D\uDC67\u200D\uD83D\uDC67".asGraphemeSequence() -> "a", "Ⓑ", "☷", ":family-woman-woman-girl-girl:"
-
Colors & Formatting
"string in".cyan() + "or" + "bold".bold()
-
JUnit Extensions, e.g.
@Test fun InMemoryLogger.`should work`() { logLine { "`、ヽ`ヽ`、ヽ(ノ><)ノ `、ヽ`☂ヽ`、ヽ" } }
leaves the console clean.
Whereas if run with@Debug
annotated or simply as the single test, the logger prints to the console.@Debug @Test fun InMemoryLogger.`should work`() { logLine { "`、ヽ`ヽ`、ヽ(ノ><)ノ `、ヽ`☂ヽ`、ヽ" } }
╭─────╴MyTest ➜ should work │ `、ヽ`ヽ`、ヽ(ノ><)ノ `、ヽ`☂ヽ`、ヽ ╰─────╴✔
Use
debug
to check what's actually inside aString
:"a b\n".debug // a ❲THREE-PER-EM SPACE❳ b ⏎␊ "�" // D800▌﹍ (low surrogate with a missing high surroage)