aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/kotlin/moe/nea/firm/ManagedConfig.kt20
-rw-r--r--src/main/kotlin/moe/nea/firm/User.kt9
2 files changed, 6 insertions, 23 deletions
diff --git a/src/main/kotlin/moe/nea/firm/ManagedConfig.kt b/src/main/kotlin/moe/nea/firm/ManagedConfig.kt
index 87d35cc..0c2b8b4 100644
--- a/src/main/kotlin/moe/nea/firm/ManagedConfig.kt
+++ b/src/main/kotlin/moe/nea/firm/ManagedConfig.kt
@@ -5,36 +5,18 @@ import kotlin.enums.enumEntries
abstract class ManagedConfig(val identifier: String) {
- protected fun <T : Any> option(
- propertyName: String,
- default: () -> T,
-// handler: OptionHandler<T>
- ): ManagedOption<T> {
- return TODO()
- }
-
protected fun <E : Any> choice(
- propertyName: String,
- universe: List<E>,
codec: Codec<E>,
renderer: EnumRenderer<E>,
- default: () -> E
): ManagedOption<E> {
- return option(propertyName, default,
-// ChoiceHandler(universe, codec, renderer)
- )
+ return TODO()
}
protected inline fun <reified E> choice(
- propertyName: String,
- noinline default: () -> E
): ManagedOption<E> where E : Enum<E>, E : StringIdentifiable {
return choice(
- propertyName,
- enumEntries<E>().toList(),
StringIdentifiable.createCodec { enumValues<E>() },
EnumRenderer.default(),
- default
)
}
}
diff --git a/src/main/kotlin/moe/nea/firm/User.kt b/src/main/kotlin/moe/nea/firm/User.kt
index 09b0b73..080f93a 100644
--- a/src/main/kotlin/moe/nea/firm/User.kt
+++ b/src/main/kotlin/moe/nea/firm/User.kt
@@ -4,10 +4,11 @@ import ext.StringIdentifiable
import kotlin.enums.enumEntries
object User : ManagedConfig("test") {
- val option by choice("name") { TestEnum.A }
- val optionAlt by choice("name", enumEntries<TestEnum>(),
+ val option by choice<TestEnum>()
+ val optionAlt by choice<TestEnum>(enumEntries<TestEnum>(),
StringIdentifiable.createCodec { enumValues<TestEnum>() },
- EnumRenderer.default<TestEnum>()) { TestEnum.A }
+ EnumRenderable.default(),
+ )
enum class TestEnum : StringIdentifiable {
A, B, C;
@@ -15,4 +16,4 @@ object User : ManagedConfig("test") {
}
fun main() {
User.option
-} \ No newline at end of file
+}