@@ -11,7 +11,7 @@ import scopt.{DefaultOEffectSetup, DefaultOParserSetup, OParser}
1111
1212import java .io .{File , PrintWriter }
1313import scala .concurrent .ExecutionContextExecutor
14- import scala .concurrent .duration .DurationInt
14+ import scala .concurrent .duration .{ DurationInt , FiniteDuration }
1515
1616object 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 ,
@@ -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 )
0 commit comments