You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.groups.OptionGroup
import com.github.ajalt.clikt.parameters.groups.provideDelegate
import com.github.ajalt.clikt.parameters.options.*
class Group : OptionGroup() {
val baseInGroup by option("--base-in-group").required()
override fun toString() = "Group(baseInGroup=$baseInGroup)"
}
class Command : CliktCommand() {
val group by Group()
val baseInCommand by option("--base-in-command").required()
val derivedGroup by option("--derived-in-group").defaultLazy { group.baseInGroup }
val derivedInCommand by option("--derived-in-command").defaultLazy { baseInCommand }
override fun toString() = """
Command(
group=$group
baseInCommand=$baseInCommand
derivedGroup=$derivedGroup
derivedInCommand=$derivedInCommand
)
""".trimIndent()
override fun run() {
println(this)
}
}
fun main(args: Array<String>) {
Command().main(listOf(
"--base-in-group", "base-in-groерup",
"--base-in-command", "base-in-command",
"--derived-in-group", "derived-in-group", // commenting this is expcetion
"--derived-in-command", "derived-in-command", // commenting this is fine
))
}
Here is exception I receive, when comment-out derived-in-command line
Exception in thread "main" java.lang.IllegalStateException: Cannot read from option delegate before parsing command line
at com.github.ajalt.clikt.parameters.internal.NullableLateinit.getValue(NullableLateinit.kt:18)
at com.github.ajalt.clikt.parameters.options.OptionWithValuesImpl.getValue(OptionWithValues.kt:184)
at com.github.ajalt.clikt.parameters.options.OptionDelegate$DefaultImpls.getValue(Option.kt:107)
at com.github.ajalt.clikt.parameters.options.OptionWithValues$DefaultImpls.getValue(OptionWithValues.kt:88)
at com.github.ajalt.clikt.parameters.options.OptionWithValuesImpl.getValue(OptionWithValues.kt:159)
at com.github.ajalt.clikt.parameters.options.OptionWithValuesImpl.getValue(OptionWithValues.kt:159)
at Group.getBaseInGroup(A.kt:7)
at Command$special$$inlined$defaultLazy$default$1.invoke(TransformAll.kt:253)
at Command$special$$inlined$defaultLazy$default$1.invoke(TransformAll.kt:97)
at com.github.ajalt.clikt.parameters.options.OptionWithValuesImpl.finalize(OptionWithValues.kt:221)
at com.github.ajalt.clikt.internal.FinalizationKt.finalizeOptions(Finalization.kt:45)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:252)
at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:40)
at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:458)
at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:455)
at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:475)
at AKt.main(A.kt:30)
The text was updated successfully, but these errors were encountered:
Consider following code
Here is exception I receive, when comment-out
derived-in-command
lineThe text was updated successfully, but these errors were encountered: