KOTLIN_BROADCAST Telegram 1909
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
👍25



tgoop.com/kotlin_broadcast/1909
Create:
Last Update:

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

BY Kotlin Multiplatform Broadcast


Share with your friend now:
tgoop.com/kotlin_broadcast/1909

View MORE
Open in Telegram


Telegram News

Date: |

Healing through screaming therapy Activate up to 20 bots While some crypto traders move toward screaming as a coping mechanism, many mental health experts have argued that “scream therapy” is pseudoscience. Scientific research or no, it obviously feels good. Invite up to 200 users from your contacts to join your channel Those being doxxed include outgoing Chief Executive Carrie Lam Cheng Yuet-ngor, Chung and police assistant commissioner Joe Chan Tung, who heads police's cyber security and technology crime bureau.
from us


Telegram Kotlin Multiplatform Broadcast
FROM American