fix compile errors
This commit is contained in:
parent
a500e1f9d3
commit
c948f70b99
3 changed files with 15 additions and 8 deletions
|
@ -1,5 +1,7 @@
|
||||||
package net.kemitix.s3thorp
|
package net.kemitix.s3thorp
|
||||||
|
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
import cats.effect.ExitCase.{Canceled, Completed, Error}
|
import cats.effect.ExitCase.{Canceled, Completed, Error}
|
||||||
import cats.effect.{ExitCode, IO, IOApp}
|
import cats.effect.{ExitCode, IO, IOApp}
|
||||||
|
|
||||||
|
@ -7,10 +9,13 @@ object Main extends IOApp {
|
||||||
|
|
||||||
def putStrLn(value: String) = IO { println(value) }
|
def putStrLn(value: String) = IO { println(value) }
|
||||||
|
|
||||||
|
val defaultConfig: Config =
|
||||||
|
Config("(none)", "", Paths.get(".").toAbsolutePath)
|
||||||
|
|
||||||
def program(args: List[String]): IO[ExitCode] =
|
def program(args: List[String]): IO[ExitCode] =
|
||||||
for {
|
for {
|
||||||
_ <- putStrLn("S3Thorp - hashed sync for s3")
|
_ <- putStrLn("S3Thorp - hashed sync for s3")
|
||||||
a <- ParseArgs(args)
|
a <- ParseArgs(args, defaultConfig)
|
||||||
_ <- Sync(a)
|
_ <- Sync(a)
|
||||||
} yield ExitCode.Success
|
} yield ExitCode.Success
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package net.kemitix.s3thorp
|
package net.kemitix.s3thorp
|
||||||
|
|
||||||
import scopt.OParser
|
import java.nio.file.Paths
|
||||||
import scopt.OParser.{builder,sequence, parse}
|
|
||||||
import cats.effect.IO
|
import cats.effect.IO
|
||||||
|
import scopt.OParser
|
||||||
|
import scopt.OParser.{builder, parse, sequence}
|
||||||
|
|
||||||
object ParseArgs {
|
object ParseArgs {
|
||||||
|
|
||||||
|
@ -13,7 +15,7 @@ object ParseArgs {
|
||||||
programName("S3Thorp"),
|
programName("S3Thorp"),
|
||||||
head("s3thorp"),
|
head("s3thorp"),
|
||||||
opt[String]('s', "source")
|
opt[String]('s', "source")
|
||||||
.action((str, c) => c.copy(source = str))
|
.action((str, c) => c.copy(source = Paths.get(str)))
|
||||||
.required()
|
.required()
|
||||||
.text("Source directory to sync to S3"),
|
.text("Source directory to sync to S3"),
|
||||||
opt[String]('b', "bucket")
|
opt[String]('b', "bucket")
|
||||||
|
@ -26,8 +28,8 @@ object ParseArgs {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
def apply(args: List[String]): IO[Config] =
|
def apply(args: List[String], defaultConfig: Config): IO[Config] =
|
||||||
parse(configParser, args, Config()) match {
|
parse(configParser, args, defaultConfig) match {
|
||||||
case Some(config) => IO.pure(config)
|
case Some(config) => IO.pure(config)
|
||||||
case _ => IO.raiseError(new IllegalArgumentException)
|
case _ => IO.raiseError(new IllegalArgumentException)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.kemitix.s3thorp
|
package net.kemitix.s3thorp
|
||||||
|
|
||||||
import java.nio.file.{Path, Paths}
|
import java.nio.file.Path
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
import cats.effect._
|
import cats.effect._
|
||||||
|
@ -13,7 +13,7 @@ object Sync extends LocalFileStream with S3MetaDataEnricher {
|
||||||
def apply(c: Config): IO[Unit] = for {
|
def apply(c: Config): IO[Unit] = for {
|
||||||
_ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}")
|
_ <- putStrLn(s"Bucket: ${c.bucket}, Prefix: ${c.prefix}, Source: ${c.source}")
|
||||||
_ <- {
|
_ <- {
|
||||||
streamDirectoryPaths(Paths.get(c.source)).flatMap(
|
streamDirectoryPaths(c.source).flatMap(
|
||||||
enrichWithS3MetaData).flatMap(
|
enrichWithS3MetaData).flatMap(
|
||||||
uploadRequiredFilter).flatMap(
|
uploadRequiredFilter).flatMap(
|
||||||
performUpload).compile.drain
|
performUpload).compile.drain
|
||||||
|
|
Loading…
Reference in a new issue