[main] Add source directory config option
This commit is contained in:
parent
8a18171d7d
commit
a4cf1d716b
2 changed files with 6 additions and 3 deletions
|
@ -1,7 +1,8 @@
|
|||
package net.kemitix.s3thorp
|
||||
|
||||
case class Config(bucket: String,
|
||||
prefix: String
|
||||
prefix: String,
|
||||
source: String
|
||||
) {
|
||||
|
||||
}
|
||||
|
|
|
@ -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] =
|
||||
|
|
Loading…
Reference in a new issue