Skip to content

Instantly share code, notes, and snippets.

@yoeluk
Created November 4, 2015 00:33
Show Gist options
  • Save yoeluk/2516c31ac631843e98ef to your computer and use it in GitHub Desktop.
Save yoeluk/2516c31ac631843e98ef to your computer and use it in GitHub Desktop.
$ ./amm
Loading...
Welcome to the Ammonite Repl 0.4.7
(Scala 2.11.7 Java 1.8.0_45)
@ load.ivy("com.typesafe" % "config" % "1.3.0")

@ val configString = """
					 |app {
					 |  root = "baseDir"
					 |  temp = ${app.root}"/temp"
					 |}""".stripMargin
configString: String = """
app {
  root = "baseDir"
  temp = ${app.root}"/temp"
}
"""

@ import com.typesafe.config.ConfigFactory
import com.typesafe.config.ConfigFactory

@ val unresolvedConfig = ConfigFactory.parseString(configString)
unresolvedConfig: com.typesafe.config.Config = Config(SimpleConfigObject({"app":{"root":"baseDir","temp":${app.root}"/temp"}}))

@ import com.typesafe.config.ConfigValueFactory
import com.typesafe.config.ConfigValueFactory

@ val rootDirectory = ConfigValueFactory.fromAnyRef("homeDir")
rootDirectory: ConfigValue = Quoted("homeDir")

@ val updatedConfig = unresolvedConfig.withValue("app.root", rootDirectory).resolve
updatedConfig: com.typesafe.config.Config = Config(SimpleConfigObject({"app":{"root":"homeDir","temp":"homeDir/temp"}}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment