@@ -11,7 +11,7 @@ import scopt.{DefaultOEffectSetup, DefaultOParserSetup, OParser}
11
11
12
12
import java .io .{File , PrintWriter }
13
13
import scala .concurrent .ExecutionContextExecutor
14
- import scala .concurrent .duration .DurationInt
14
+ import scala .concurrent .duration .{ DurationInt , FiniteDuration }
15
15
16
16
object App {
17
17
private val logger = LoggerFactory .getLogger(getClass.getName.replaceFirst(" \\ $$" , " " ))
@@ -27,7 +27,7 @@ object App {
27
27
implicit val system : ActorSystem [Nothing ] = ActorSystem (Behaviors .empty, " WhatIsMyIpAddress" )
28
28
implicit val ec : ExecutionContextExecutor = system.executionContext
29
29
30
- MyipcomInfoProvider ().info(1 .minute )
30
+ MyipcomInfoProvider ().info(config.interval )
31
31
.addAttributes(Attributes .logLevels(
32
32
onElement = Logging .DebugLevel ,
33
33
onFinish = Logging .InfoLevel ,
@@ -73,7 +73,7 @@ object App {
73
73
74
74
OParser .sequence(
75
75
programName(" whatismyip" ),
76
- head(" whatismyip" , " 1.2 .0" ),
76
+ head(" whatismyip" , " 1.3 .0" ),
77
77
opt[Option [File ]]('f' , " file" )
78
78
.action((x, c) => c.copy(file = x))
79
79
.validate {
@@ -89,6 +89,13 @@ object App {
89
89
case None => success
90
90
}
91
91
.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)" ),
92
99
help(" help" ).text(" prints this usage text" ),
93
100
version(" version" )
94
101
)
0 commit comments