mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
feat(partnerctl): add details output helper for key-value prompt sections
This commit is contained in:
@@ -49,6 +49,18 @@ class Prompt private constructor(
|
|||||||
|
|
||||||
fun info(message: String) = println("[info] $message")
|
fun info(message: String) = println("[info] $message")
|
||||||
|
|
||||||
|
fun details(title: String? = null, items: List<Pair<String, String>>) {
|
||||||
|
if (items.isEmpty()) return
|
||||||
|
|
||||||
|
if (!title.isNullOrBlank()) {
|
||||||
|
println(title)
|
||||||
|
}
|
||||||
|
|
||||||
|
items.forEach { (key, value) ->
|
||||||
|
println(" $key: $value")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun success(message: String) = println("[ok] $message")
|
fun success(message: String) = println("[ok] $message")
|
||||||
|
|
||||||
fun warn(message: String) = println("[warn] $message")
|
fun warn(message: String) = println("[warn] $message")
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ fun main() {
|
|||||||
}
|
}
|
||||||
prompt.info("Port = $port")
|
prompt.info("Port = $port")
|
||||||
|
|
||||||
|
prompt.details(
|
||||||
|
"Test Details", listOf(
|
||||||
|
"Tag A" to "Detail A",
|
||||||
|
"Tag B" to "Detail B"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
prompt.section("Confirm")
|
prompt.section("Confirm")
|
||||||
val confirmed = prompt.confirm("Continue?", defaultValue = true)
|
val confirmed = prompt.confirm("Continue?", defaultValue = true)
|
||||||
prompt.info("Continue = $confirmed")
|
prompt.info("Continue = $confirmed")
|
||||||
|
|||||||
Reference in New Issue
Block a user