Skip to content

Instantly share code, notes, and snippets.

@kastoestoramadus
Last active April 24, 2025 15:44
Show Gist options
  • Save kastoestoramadus/407bd8eecd33325e5143993a7230d6b7 to your computer and use it in GitHub Desktop.
Save kastoestoramadus/407bd8eecd33325e5143993a7230d6b7 to your computer and use it in GitHub Desktop.
scala script
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))
}
}
@kastoestoramadus
Copy link
Author

kastoestoramadus commented Apr 24, 2025

root {
  params {
        db {
        schema: ${root.schemas.BLA.name}
        }
     }  
  feed {
    scheduler=tables_full
    params {
      num-map=1
    }
    name="ALBABLA"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment