Skip to content

Commit 365314e

Browse files
Merge branch 'release/v1.3.0'
2 parents 7392b0b + 836efb7 commit 365314e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name := "whatismyip"
22

3-
version := "1.2.0"
3+
version := "1.3.0"
44

55
scalaVersion := "2.13.5"
66

src/main/scala/com/github/invis1ble/whatismyip/App.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scopt.{DefaultOEffectSetup, DefaultOParserSetup, OParser}
1111

1212
import java.io.{File, PrintWriter}
1313
import scala.concurrent.ExecutionContextExecutor
14-
import scala.concurrent.duration.DurationInt
14+
import scala.concurrent.duration.{DurationInt, FiniteDuration}
1515

1616
object App {
1717
private val logger = LoggerFactory.getLogger(getClass.getName.replaceFirst("\\$$", ""))
@@ -27,7 +27,7 @@ object App {
2727
implicit val system: ActorSystem[Nothing] = ActorSystem(Behaviors.empty, "WhatIsMyIpAddress")
2828
implicit val ec: ExecutionContextExecutor = system.executionContext
2929

30-
MyipcomInfoProvider().info(1.minute)
30+
MyipcomInfoProvider().info(config.interval)
3131
.addAttributes(Attributes.logLevels(
3232
onElement = Logging.DebugLevel,
3333
onFinish = Logging.InfoLevel,
@@ -73,7 +73,7 @@ object App {
7373

7474
OParser.sequence(
7575
programName("whatismyip"),
76-
head("whatismyip", "1.2.0"),
76+
head("whatismyip", "1.3.0"),
7777
opt[Option[File]]('f', "file")
7878
.action((x, c) => c.copy(file = x))
7979
.validate {
@@ -89,6 +89,13 @@ object App {
8989
case None => success
9090
}
9191
.text("Output file (will be created if not exists)"),
92+
opt[FiniteDuration]('i', "interval")
93+
.action((x, c) => c.copy(interval = x))
94+
.validate { interval =>
95+
if (interval >= 1.second) success
96+
failure("Interval must be >= 1 second")
97+
}
98+
.text("update interval (in Scala's Duration format)"),
9299
help("help").text("prints this usage text"),
93100
version("version")
94101
)
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.github.invis1ble.whatismyip
22

33
import java.io.File
4+
import scala.concurrent.duration.{DurationInt, FiniteDuration}
45

5-
final case class Config(file: Option[File] = None)
6+
final case class Config(
7+
file: Option[File] = None,
8+
interval: FiniteDuration = 1.minute,
9+
)

0 commit comments

Comments
 (0)