Kotlin Multiplatform Broadcast
9.48K subscribers
838 photos
52 videos
1.13K links
Новости и фичи Kotlin, а также Kotlin Multiplatform

YouTubе канал: https://youtube.com/androidBroadcast
Compose Multiplatform @compose_broadcast
iOS разработка @ios_broadcast
Новости Android @android_broadcast
Реклама и прочее @ab_manager
加入频道
readline4k - Kotlin/Native библиотека для разработки консольных интерактивных приложений для Desktop

val history = "history.txt" // Filesystem path to the history file.

// Configure the LineEditor.
val config = LineEditorConfig(
maxHistorySize = 100,
completionType = CompletionType.LIST,
// See the documentation for more options.
)

// Create a new LineEditor instance.
val editor = SimpleLineEditor(
linePrefix = "> ",
config = config,
).also { editor ->
// Set up the completer and highlighter.
editor
// Provides file completion (optional).
.withCompleter(SimpleFileCompleter())
// Provides color highlighting (optional).
.withHighlighter(SimpleHighlighter())

// Load the history from the disk (throws LineEditorError if it fails).
editor.loadHistory(history).getOrThrow()
}

println("Welcome to the LineEditor example!")
println("Press Ctrl+C to exit")

while (true) {
// Read a line from the user.
editor.readLine()
.onFailure { err ->
// err is a LineEditorError
println(err.message)
break

}
.onSuccess { line ->
// We can also add the line to the history
// automatically by setting autoAddHistory = true in the config.
editor.addHistoryEntry(line)
println(line)
}
}

// Save the history to disk.
editor.saveHistory(history)


#kotlin #native #cli
👍20