refactor rename to application.yaml
This commit is contained in:
1 parent
807d466b31
commit
debe6c92c8
2 files changed
+4
-7
No files matched your search
@@ -43,8 +43,8 @@ fun loadConfig(): ConfigResult {
|
||||
|
||||
// External files take precedence (production use)
|
||||
val externalLocations = listOf(
|
||||
File(System.getProperty("user.home"), ".anytask/anytask.yaml"),
|
||||
File("anytask.yaml"),
|
||||
File(System.getProperty("user.home"), ".anytask/application.yaml"),
|
||||
File("application.yaml"),
|
||||
)
|
||||
externalLocations.firstOrNull { it.exists() }?.let { file ->
|
||||
val config = yaml.decodeFromString(serializer, file.readText())
|
||||
@@ -53,7 +53,7 @@ fun loadConfig(): ConfigResult {
|
||||
}
|
||||
|
||||
// Fallback: classpath resource (development)
|
||||
Configuration::class.java.getResourceAsStream("/anytask.yaml")?.let { stream ->
|
||||
Configuration::class.java.getResourceAsStream("/application.yaml")?.let { stream ->
|
||||
val config = yaml.decodeFromString(serializer, stream.bufferedReader().readText())
|
||||
logger.info("Loaded config from classpath:/anytask.yaml")
|
||||
return ConfigResult(config, null)
|
||||
@@ -64,7 +64,7 @@ fun loadConfig(): ConfigResult {
|
||||
}
|
||||
|
||||
fun saveConfig(config: Configuration, sourceFile: File?) {
|
||||
val file = sourceFile ?: File(System.getProperty("user.home"), ".anytask/anytask.yaml")
|
||||
val file = sourceFile ?: File(System.getProperty("user.home"), ".anytask/application.yaml")
|
||||
file.parentFile?.mkdirs()
|
||||
val yaml = Yaml.default
|
||||
file.writeText(yaml.encodeToString(Configuration.serializer(), config))
|
||||
|
||||