@@ -247,6 +247,19 @@ case class Settings(
247247 cwd = dir
248248 )
249249 }
250+
251+ def withCliArgs (args : List [String ]): Configured [Settings ] = {
252+ Conf .parseCliArgs[Settings ](args).andThen { conf =>
253+ val withCwd = conf.get[String ](" cwd" ).map { x =>
254+ implicit val defaultCwd : AbsolutePath = this .cwd
255+ withWorkingDirectory(AbsolutePath (x))
256+ }.getOrElse(this )
257+ val base = conf.get[String ](" propertyFileName" )
258+ .map(withCwd.withPropertiesFromFile).getOrElse(withCwd)
259+ conf.as[Settings ](Settings .decoder(base)).map(_.addSite(base.site))
260+ }
261+ }
262+
250263}
251264
252265object Settings { // extends MetaconfigScalametaImplicits with Decoders with SettingsGeneric {
@@ -306,20 +319,8 @@ object Settings { // extends MetaconfigScalametaImplicits with Decoders with Set
306319 generic.deriveDecoder[Settings ](base)
307320 }
308321
309- def fromCliArgs (args : List [String ], workingDirectory : => AbsolutePath ): Configured [Settings ] = {
310- Conf
311- .parseCliArgs[Settings ](args)
312- .andThen { conf =>
313- implicit val defaultCwd : AbsolutePath = workingDirectory
314- val base = Settings (
315- conf.get[String ](" cwd" ).map(AbsolutePath (_)).getOrElse(defaultCwd),
316- conf.get[String ](" propertyFileName" ).getOrElse(" mdoc.properties" )
317- )
318- conf
319- .as[Settings ](decoder(base))
320- .map(_.addSite(base.site))
321- }
322- }
322+ def fromCliArgs (args : List [String ], workingDirectory : AbsolutePath ): Configured [Settings ] =
323+ Settings (workingDirectory, " mdoc.properties" ).withCliArgs(args)
323324
324325 def fromCliArgs (args : List [String ], workingDirectory : Path ): Configured [Settings ] =
325326 fromCliArgs(args, AbsolutePath (workingDirectory))
0 commit comments