scala - Passing Command-Line Arguments to SBT for Setting TypeSafe Config Key-Value -


given following "main" app:

package net  import com.typesafe.config.configfactory  object main extends app {     override def main(args: array[string]) {         val x = configfactory.load().getstring("app.bar")         println(s"x: $x")     } } 

and application.conf:

app {     bar = ${?bar} } 

i pass in command-line argument via:

$sbt test:run -dbar=bippy [info] set current project typesafe_config_env_var      (in build file:.../typesafe_config_env_var/) [info] running net.main  x: bippy 

i wrote simple example try reproduce problem resolving command-line argument. however, output above shows, test worked successfully.

is standard way of passing command-line arguments in sbt?

depends on mean standard. afaik, "standard" way of passing arguments:

$ sbt "run --bippy" 

your example using feature typesafe config binds environment variables application.conf definitions. here's tutorial that.


Comments