This commit is contained in:
Aria Moradi
2021-08-30 02:44:35 +04:30
parent 37cf80a188
commit 38ad4c6dec
2 changed files with 19 additions and 14 deletions

View File

@@ -14,8 +14,13 @@ import kotlin.reflect.KProperty
/**
* Abstract config module.
*/
abstract class ConfigModule(config: Config, moduleName: String = "") {
val overridableWithSysProperty = SystemPropertyOverrideDelegate(config, moduleName)
abstract class ConfigModule(config: Config)
/**
* Abstract jvm-commandline-argument-overridable config module.
*/
abstract class SystemPropertyOverridableConfigModule(config: Config, moduleName: String): ConfigModule(config) {
val overridableConfig = SystemPropertyOverrideDelegate(config, moduleName)
}
/** Defines a config property that is overridable with jvm `-D` commandline arguments prefixed with [CONFIG_PREFIX] */

View File

@@ -8,30 +8,30 @@ package suwayomi.tachidesk.server
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import com.typesafe.config.Config
import xyz.nulldev.ts.config.ConfigModule
import xyz.nulldev.ts.config.GlobalConfigManager
import xyz.nulldev.ts.config.SystemPropertyOverridableConfigModule
import xyz.nulldev.ts.config.debugLogsEnabled
private const val MODULE_NAME = "server"
class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : ConfigModule(config, moduleName) {
val ip: String by overridableWithSysProperty
val port: Int by overridableWithSysProperty
class ServerConfig(config: Config, moduleName: String = MODULE_NAME) : SystemPropertyOverridableConfigModule(config, moduleName) {
val ip: String by overridableConfig
val port: Int by overridableConfig
// proxy
val socksProxyEnabled: Boolean by overridableWithSysProperty
val socksProxyEnabled: Boolean by overridableConfig
val socksProxyHost: String by overridableWithSysProperty
val socksProxyPort: String by overridableWithSysProperty
val socksProxyHost: String by overridableConfig
val socksProxyPort: String by overridableConfig
// misc
val debugLogsEnabled: Boolean = debugLogsEnabled(GlobalConfigManager.config)
val systemTrayEnabled: Boolean by overridableWithSysProperty
val systemTrayEnabled: Boolean by overridableConfig
// webUI
val webUIEnabled: Boolean by overridableWithSysProperty
val initialOpenInBrowserEnabled: Boolean by overridableWithSysProperty
val webUIInterface: String by overridableWithSysProperty
val electronPath: String by overridableWithSysProperty
val webUIEnabled: Boolean by overridableConfig
val initialOpenInBrowserEnabled: Boolean by overridableConfig
val webUIInterface: String by overridableConfig
val electronPath: String by overridableConfig
companion object {
fun register(config: Config) = ServerConfig(config.getConfig(MODULE_NAME))