fix compile errors

This commit is contained in:
Paul Campbell 2019-05-07 20:40:11 +01:00
parent a500e1f9d3
commit c948f70b99
3 changed files with 15 additions and 8 deletions

View file

@ -1,5 +1,7 @@
package net.kemitix.s3thorp
import java.nio.file.Paths
import cats.effect.ExitCase.{Canceled, Completed, Error}
import cats.effect.{ExitCode, IO, IOApp}
@ -7,10 +9,13 @@ object Main extends IOApp {
def putStrLn(value: String) = IO { println(value) }
val defaultConfig: Config =
Config("(none)", "", Paths.get(".").toAbsolutePath)
def program(args: List[String]): IO[ExitCode] =
for {
_ <- putStrLn("S3Thorp - hashed sync for s3")
a <- ParseArgs(args)
a <- ParseArgs(args, defaultConfig)
_ <- Sync(a)
} yield ExitCode.Success

View file

@ -1,8 +1,10 @@
package net.kemitix.s3thorp
import scopt.OParser
import scopt.OParser.{builder,sequence, parse}
import java.nio.file.Paths
import cats.effect.IO
import scopt.OParser
import scopt.OParser.{builder, parse, sequence}
object ParseArgs {
@ -13,7 +15,7 @@ object ParseArgs {
programName("S3Thorp"),
head("s3thorp"),
opt[String]('s', "source")
.action((str, c) => c.copy(source = str))
.action((str, c) => c.copy(source = Paths.get(str)))
.required()
.text("Source directory to sync to S3"),
opt[String]('b', "bucket")
@ -26,8 +28,8 @@ object ParseArgs {
)
}
def apply(args: List[String]): IO[Config] =
parse(configParser, args, Config()) match {
def apply(args: List[String], defaultConfig: Config): IO[Config] =
parse(configParser, args, defaultConfig) match {
case Some(config) => IO.pure(config)
case _ => IO.raiseError(new IllegalArgumentException)
}

View file

@ -1,6 +1,6 @@
package net.kemitix.s3thorp
import java.nio.file.{Path, Paths}
import java.nio.file.Path
import java.time.Instant
import cats.effect._
@ -13,7 +13,7 @@ object Sync extends LocalFileStream with S3MetaDataEnricher {
def apply(c: Config): IO[Unit] = for {
_ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}")
_ <- {
streamDirectoryPaths(Paths.get(c.source)).flatMap(
streamDirectoryPaths(c.source).flatMap(
enrichWithS3MetaData).flatMap(
uploadRequiredFilter).flatMap(
performUpload).compile.drain