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: |

Informative 6How to manage your Telegram channel? How to create a business channel on Telegram? (Tutorial) Find your optimal posting schedule and stick to it. The peak posting times include 8 am, 6 pm, and 8 pm on social media. Try to publish serious stuff in the morning and leave less demanding content later in the day. How to create a business channel on Telegram? (Tutorial)
from us


Telegram Kotlin Multiplatform Broadcast
FROM American