From aab2fdde3d346276f392abf0c583b016de791405 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 6 May 2019 17:20:28 +0100 Subject: [PATCH] [sync] Extract Sync class --- src/main/scala/net/kemitix/s3thorp/Main.scala | 7 +------ src/main/scala/net/kemitix/s3thorp/Sync.scala | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/main/scala/net/kemitix/s3thorp/Sync.scala diff --git a/src/main/scala/net/kemitix/s3thorp/Main.scala b/src/main/scala/net/kemitix/s3thorp/Main.scala index 3338c20..a6fda47 100644 --- a/src/main/scala/net/kemitix/s3thorp/Main.scala +++ b/src/main/scala/net/kemitix/s3thorp/Main.scala @@ -7,16 +7,11 @@ object Main extends IOApp { def putStrLn(value: String) = IO { println(value) } - def sync(c: Config): IO[Unit] = - for { - _ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}") - } yield () - def program(args: List[String]): IO[ExitCode] = for { _ <- putStrLn("S3Thorp - hashed sync for s3") a <- ParseArgs(args) - _ <- sync(a) + _ <- Sync(a) } yield ExitCode.Success override def run(args: List[String]): IO[ExitCode] = diff --git a/src/main/scala/net/kemitix/s3thorp/Sync.scala b/src/main/scala/net/kemitix/s3thorp/Sync.scala new file mode 100644 index 0000000..e0714e2 --- /dev/null +++ b/src/main/scala/net/kemitix/s3thorp/Sync.scala @@ -0,0 +1,12 @@ +package net.kemitix.s3thorp + +import cats._ +import cats.effect._ +import Main.putStrLn + +object Sync { + def apply(c: Config): IO[Unit] = for { + _ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}") + } yield () + +}