[parseArgs,Config] Move defaults to Config

This commit is contained in:
Paul Campbell 2019-05-06 11:34:15 +01:00
parent 7ce0b26d4f
commit de5cd375d2
2 changed files with 4 additions and 6 deletions

View file

@ -1,8 +1,8 @@
package net.kemitix.s3thorp package net.kemitix.s3thorp
case class Config(bucket: String, case class Config(bucket: String = "",
prefix: String, prefix: String = "",
source: String source: String = ""
) { ) {
} }

View file

@ -6,8 +6,6 @@ import cats.effect.IO
object ParseArgs { object ParseArgs {
val defaultConfig = Config("def-bucket", "def-prefix", "def-source")
val configParser: OParser[Unit, Config] = { val configParser: OParser[Unit, Config] = {
val parserBuilder = builder[Config] val parserBuilder = builder[Config]
import parserBuilder._ import parserBuilder._
@ -27,7 +25,7 @@ object ParseArgs {
} }
def apply(args: List[String]): IO[Config] = def apply(args: List[String]): IO[Config] =
parse(configParser, args, defaultConfig) match { parse(configParser, args, Config()) match {
case Some(config) => IO.pure(config) case Some(config) => IO.pure(config)
case _ => IO.raiseError(new IllegalArgumentException) case _ => IO.raiseError(new IllegalArgumentException)
} }