-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Konf examples #43
Comments
Same result with: data class Configuration(val tasks: List<String>, val options: List<String>) {
companion object : ConfigSpec("configuration") {
val tasks by TestSpec.ConfigurationSpec.required<List<String>>()
val options by TestSpec.ConfigurationSpec.optional<List<String>>(emptyList())
}
}
data class Expectation(val file_exists: List<String>) {
companion object : ConfigSpec("expectation") {
val file_exists by TestSpec.ExpectationSpec.optional<List<String>>(emptyList())
}
}
data class Test(val description: String, val configuration: Configuration, val expectation: Expectation) {
companion object : ConfigSpec("") {
val description by required<String>()
val configuration by required<Configuration>()
val expectation by required<Expectation>()
}
}
object Root : ConfigSpec("") {
val tests by required<List<Test>>()
} I think the most unclear thing to me is how specifications get bound to objects besides built-in ones |
I'm closing this by myself: specs were not being loaded into the data class Configuration(val tasks: List<String>, val options: List<String>) {
companion object : ConfigSpec() {
val tasks by TestSpec.ConfigurationSpec.required<List<String>>()
val options by TestSpec.ConfigurationSpec.optional<List<String>>(emptyList())
}
}
data class Expectation(val file_exists: List<String>) {
companion object : ConfigSpec() {
val file_exists by TestSpec.ExpectationSpec.optional<List<String>>(emptyList())
}
}
data class Test(val description: String, val configuration: Configuration, val expectation: Expectation) {
companion object : ConfigSpec() {
val description by required<String>()
val configuration by required<Configuration>()
val expectation by required<Expectation>()
}
}
object Root : ConfigSpec("") {
val tests by required<List<Test>>()
}
val testConfiguration = Config({
addSpec(Root)
addSpec(Test)
addSpec(Expectation)
addSpec(Configuration)
}).from.yaml.inputStream(it.open())
println(testConfiguration[Root.tests]) prints out: |
Hi,
where can I find a library of examples for konf? I'm trying to get past the base example presented, but I can't understand how to do more advanced stuff with the library.
I want to parse e.g.:
I tried the following:
But this causes:
It's unclear to me why and how can I debug this.
Thanks!
The text was updated successfully, but these errors were encountered: