@@ -247,6 +247,18 @@ 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 propsFile = conf.get[String ](" propertyFileName" ).getOrElse(" mdoc.properties" )
254+ val base = conf.get[String ](" cwd" ).map { x =>
255+ implicit val defaultCwd : AbsolutePath = this .cwd
256+ withWorkingDirectory(AbsolutePath (x))
257+ }.getOrElse(this ).withPropertiesFromFile(propsFile)
258+ conf.as[Settings ](Settings .decoder(base)).map(_.addSite(base.site))
259+ }
260+ }
261+
250262}
251263
252264object Settings { // extends MetaconfigScalametaImplicits with Decoders with SettingsGeneric {
@@ -306,20 +318,8 @@ object Settings { // extends MetaconfigScalametaImplicits with Decoders with Set
306318 generic.deriveDecoder[Settings ](base)
307319 }
308320
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- }
321+ def fromCliArgs (args : List [String ], workingDirectory : AbsolutePath ): Configured [Settings ] =
322+ Settings (workingDirectory).withCliArgs(args)
323323
324324 def fromCliArgs (args : List [String ], workingDirectory : Path ): Configured [Settings ] =
325325 fromCliArgs(args, AbsolutePath (workingDirectory))
0 commit comments