Skip to content

Commit

Permalink
rename better suits function
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-MX committed Jun 14, 2024
1 parent bbeef0f commit c7357dc
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mattmx.ktgui.commands.declarative.arg

import com.google.gson.JsonParser
import com.mattmx.ktgui.commands.declarative.arg.impl.*
import kotlin.math.min

Expand Down Expand Up @@ -43,7 +44,7 @@ class ArgumentProcessor(
values[argId] = next() ?: return
}

fun takeUntilNot(argId: String, block: String.() -> Boolean) {
fun takeWhile(argId: String, block: String.() -> Boolean) {
var current = next()
val list = arrayListOf<String>()

Expand All @@ -61,7 +62,7 @@ class ArgumentProcessor(
}

fun takeRemaining(argId: String) {
takeUntilNot(argId) { pointer < args.size }
takeWhile(argId) { pointer < args.size }
}
}

Expand All @@ -75,8 +76,13 @@ fun main() {

processor.permittedFlags.add(ping)

// We should abstract this using the `ArgumentConsumer` interface
processor.takeOne("username")
processor.takeRemaining("msg")

println(processor.values)
username consumes single()
msg consumes until { false }
msg consumes remaining()

println(processor)
}

0 comments on commit c7357dc

Please sign in to comment.