From a4cf1d716b9bd2a67f03c0ea61114d8cffa87fa4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 6 May 2019 10:54:42 +0100 Subject: [PATCH] [main] Add source directory config option --- src/main/scala/net/kemitix/s3thorp/Config.scala | 3 ++- src/main/scala/net/kemitix/s3thorp/Main.scala | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/scala/net/kemitix/s3thorp/Config.scala b/src/main/scala/net/kemitix/s3thorp/Config.scala index 67de1c2..fad09e1 100644 --- a/src/main/scala/net/kemitix/s3thorp/Config.scala +++ b/src/main/scala/net/kemitix/s3thorp/Config.scala @@ -1,7 +1,8 @@ package net.kemitix.s3thorp case class Config(bucket: String, - prefix: String + prefix: String, + source: String ) { } diff --git a/src/main/scala/net/kemitix/s3thorp/Main.scala b/src/main/scala/net/kemitix/s3thorp/Main.scala index 659eb1f..16371ff 100644 --- a/src/main/scala/net/kemitix/s3thorp/Main.scala +++ b/src/main/scala/net/kemitix/s3thorp/Main.scala @@ -13,6 +13,8 @@ object Main extends IOApp { OParser.sequence( programName("S3Thorp"), head("s3thorp", "0.1.0"), + opt[String]('s', "source") + .action((str, c) => c.copy(source = str)), opt[String]('b', "bucket") .action((str, c) => c.copy(bucket = str)) .text("S3 bucket name"), @@ -21,7 +23,7 @@ object Main extends IOApp { .text("Prefix within the S3 Bucket") ) } - val defaultConfig = Config("def-bucket", "def-prefix") + val defaultConfig = Config("def-bucket", "def-prefix", "def-source") OParser.parse(configParser, args, defaultConfig) match { case Some(config) => IO.pure(config) case _ => IO.raiseError(new IllegalArgumentException) @@ -33,7 +35,7 @@ object Main extends IOApp { def sync(c: Config): IO[Unit] = for { _ <- putStrLn("S3Thorp - hashed sync for s3") - _ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}") + _ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}") } yield () def program(args: List[String]): IO[ExitCode] =