Last active
April 24, 2025 15:44
-
-
Save kastoestoramadus/407bd8eecd33325e5143993a7230d6b7 to your computer and use it in GitHub Desktop.
scala script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nordea | |
import java.io.File | |
import java.nio.file.{Path, Paths} | |
import org.ekrich.config.{Config, ConfigFactory, ConfigParseOptions, ConfigRenderOptions} | |
object HoconFormatter { | |
def main(args: Array[String]): Unit = { | |
println(s"Running HOCON formatter. pwd: ${ new File(".").getAbsolutePath}") | |
val targetFile = new File("testFeed.conf") | |
println(fmtFileToStr(targetFile)) | |
} | |
val parseOptions = ConfigParseOptions.defaults.setAllowMissing(true) | |
val renderOptions = ConfigRenderOptions.defaults | |
.setJson(false) | |
.setOriginComments(true) | |
.setComments(true) | |
.setFormatted(true) | |
def fmtFileToStr(file: File): String = | |
ConfigFactory | |
.parseFile(file, parseOptions) | |
.root | |
.render(renderOptions) | |
.replaceAll(" ", " ") | |
def replaceContent(inFile: File, withContent: String): Unit = ??? | |
def getAllConfigFiles(path: Path): List[File] = ??? | |
def reformattAllFilesIn(strPath: String) = | |
getAllConfigFiles(Paths.get(strPath)).foreach { file => | |
replaceContent(file, fmtFileToStr(file)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.