Skip to content

Commit

Permalink
Relax entries methods on select build to take iterables
Browse files Browse the repository at this point in the history
  • Loading branch information
ajalt committed Jun 29, 2024
1 parent addb257 commit ca6ad46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class InteractiveSelectListBuilder(private val terminal: Terminal) {

/** Set the list of items to select from */
@JvmName("entriesEntry")
fun entries(entries: List<SelectList.Entry>): InteractiveSelectListBuilder = apply {
fun entries(entries: Iterable<SelectList.Entry>): InteractiveSelectListBuilder = apply {
config.entries = entries.toMutableList()
}

Expand All @@ -72,7 +72,7 @@ class InteractiveSelectListBuilder(private val terminal: Terminal) {

/** Set the list of items to select from */
@JvmName("entriesString")
fun entries(entries: List<String>): InteractiveSelectListBuilder = apply {
fun entries(entries: Iterable<String>): InteractiveSelectListBuilder = apply {
config.entries = entries.mapTo(mutableListOf()) { SelectList.Entry(it) }
}

Expand Down Expand Up @@ -288,8 +288,8 @@ class InteractiveSelectListBuilder(private val terminal: Terminal) {
}
}

private open class SelectInputAnimation(
final override val terminal: Terminal,
private class SelectInputAnimation(
override val terminal: Terminal,
private val config: SelectConfig,
private val singleSelect: Boolean,
) : InputReceiverAnimation<List<String>?> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inline fun Terminal.interactiveSelectList(
*/
@JvmName("interactiveSelectListString")
fun Terminal.interactiveSelectList(
entries: List<String>,
entries: Iterable<String>,
title: String = "",
): String? {
return interactiveSelectList {
Expand All @@ -45,7 +45,7 @@ fun Terminal.interactiveSelectList(
*/
@JvmName("interactiveSelectListEntry")
fun Terminal.interactiveSelectList(
entries: List<SelectList.Entry>,
entries: Iterable<SelectList.Entry>,
title: String = "",
): String? {
return interactiveSelectList {
Expand Down Expand Up @@ -77,7 +77,7 @@ inline fun Terminal.interactiveMultiSelectList(
*/
@JvmName("interactiveMultiSelectListEntry")
fun Terminal.interactiveMultiSelectList(
entries: List<SelectList.Entry>,
entries: Iterable<SelectList.Entry>,
title: String = "",
): List<String>? {
return interactiveMultiSelectList {
Expand All @@ -95,7 +95,7 @@ fun Terminal.interactiveMultiSelectList(
*/
@JvmName("interactiveMultiSelectListString")
fun Terminal.interactiveMultiSelectList(
entries: List<String>,
entries: Iterable<String>,
title: String = "",
): List<String>? {
return interactiveMultiSelectList {
Expand Down

0 comments on commit ca6ad46

Please sign in to comment.