[parseArgs,Config] Move defaults to Config
This commit is contained in:
parent
7ce0b26d4f
commit
de5cd375d2
2 changed files with 4 additions and 6 deletions
|
@ -1,8 +1,8 @@
|
|||
package net.kemitix.s3thorp
|
||||
|
||||
case class Config(bucket: String,
|
||||
prefix: String,
|
||||
source: String
|
||||
case class Config(bucket: String = "",
|
||||
prefix: String = "",
|
||||
source: String = ""
|
||||
) {
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@ import cats.effect.IO
|
|||
|
||||
object ParseArgs {
|
||||
|
||||
val defaultConfig = Config("def-bucket", "def-prefix", "def-source")
|
||||
|
||||
val configParser: OParser[Unit, Config] = {
|
||||
val parserBuilder = builder[Config]
|
||||
import parserBuilder._
|
||||
|
@ -27,7 +25,7 @@ object ParseArgs {
|
|||
}
|
||||
|
||||
def apply(args: List[String]): IO[Config] =
|
||||
parse(configParser, args, defaultConfig) match {
|
||||
parse(configParser, args, Config()) match {
|
||||
case Some(config) => IO.pure(config)
|
||||
case _ => IO.raiseError(new IllegalArgumentException)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue