[main] extract IO program
This commit is contained in:
parent
b16862ea20
commit
b5e1036874
1 changed files with 10 additions and 5 deletions
|
@ -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"))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue