dev.forkhandles.bunting.IO.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bunting4k Show documentation
Show all versions of bunting4k Show documentation
ForkHandles CLI Flag library
package dev.forkhandles.bunting
import dev.forkhandles.bunting.Visibility.Public
import dev.forkhandles.bunting.Visibility.Secret
interface IO {
fun read(visibility: Visibility): String
fun write(message: String)
}
object ConsoleIO : IO {
override fun read(visibility: Visibility): String = when (visibility) {
Secret -> System.console()?.readPassword()?.let { String(it) } ?: read(Public)
Public -> readLine() ?: throw IllegalArgumentException("Failed to read input")
}
override fun write(message: String) = print(message)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy