diff --git a/src/main/scala/net/kemitix/s3thorp/Main.scala b/src/main/scala/net/kemitix/s3thorp/Main.scala index 4057f39..54ff2cf 100644 --- a/src/main/scala/net/kemitix/s3thorp/Main.scala +++ b/src/main/scala/net/kemitix/s3thorp/Main.scala @@ -2,16 +2,21 @@ package net.kemitix.s3thorp import cats.effect.ExitCase.{Canceled, Completed, Error} import cats.effect.{ExitCode, IO, IOApp} -import cats.syntax.all._ object Main extends IOApp { + def parseArgs(args: List[String]): IO[Config] = IO.pure(Config("", "")) + + def program(args: List[String]): IO[ExitCode] = for { + a <- parseArgs(args) + _ <- S3Thorp(a) + } yield ExitCode.Success + override def run(args: List[String]): IO[ExitCode] = - (for { - ec <- S3Thorp(args).as(ExitCode.Success) - } yield ec).guaranteeCase { + program(args) + .guaranteeCase { case Canceled => IO(println("Interrupted")) - case Error(e) => IO(println("ERROR: " + e)) + case Error(e) => IO(println("ERROR: " + e.getMessage)) case Completed => IO(println("Done")) }