Skip to content

Commit 30e382e

Browse files
committed
feat: add collapsed property/fun to OptionGroup Kt DSL
1 parent 8b1f26a commit 30e382e

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/main/kotlin/dev/isxander/yacl3/dsl/API.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ interface GroupDsl : Buildable<OptionGroup> {
125125
fun descriptionBuilder(block: OptionDescription.Builder.() -> Unit)
126126
fun OptionDescription.Builder.addDefaultText(lines: Int? = null) =
127127
addDefaultText("$groupKey.description", lines)
128+
129+
fun collapsed(collapsed: Boolean)
130+
var collapsed: Boolean
128131
}
129132

130133
interface OptionDsl<T> : Option.Builder<T>, Buildable<Option<T>> {

src/main/kotlin/dev/isxander/yacl3/dsl/Impl.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,15 @@ class GroupDslImpl(
168168
private val optionFutures = mutableMapOf<String, CompletableFuture<Option<*>>>()
169169
private fun createOptionFuture(id: String) = optionFutures.computeIfAbsent(id) { CompletableFuture() }
170170

171+
override var collapsed: Boolean = false
172+
set(value) {
173+
field = value
174+
builder.collapsed(value)
175+
}
176+
171177
init {
172178
builder.name(Component.translatable(groupKey))
179+
collapsed = false
173180
}
174181

175182
override val options: OptionRegistrar = OptionRegistrarImpl(
@@ -196,6 +203,10 @@ class GroupDslImpl(
196203
addDefaultText("$groupKey.description", lines)
197204
}
198205

206+
override fun collapsed(collapsed: Boolean) {
207+
this.collapsed = collapsed
208+
}
209+
199210
override fun build(): OptionGroup =
200211
builder.build().also {
201212
thisGroup.complete(it)

0 commit comments

Comments
 (0)