11import core.thread : Thread ;
22import std.datetime : Duration, Clock , seconds, TimeOfDay ;
33import std.format : format;
4- import std.getopt : getopt, getOptConfig = config;
4+ import std.getopt : getopt, getOptConfig = config, arraySep ;
55import std.json : JSONValue, parseJSON, JSONOptions;
66import std.logger : infof, errorf, tracef, LogLevel;
77import std.random : uniform;
@@ -14,7 +14,7 @@ struct Params
1414 Duration minWaitTime;
1515 Duration maxWaitTime;
1616 Duration alertDuration;
17- string url ;
17+ string [] urls ;
1818 TimeOfDay startTime;
1919 TimeOfDay endTime;
2020}
@@ -38,7 +38,7 @@ struct Alert
3838int main (string [] args)
3939{
4040 LogLevel logLevel = LogLevel.info;
41- string url ;
41+ string [] urls ;
4242 string startTime = " 00:00:00" ;
4343 string endTime = " 23:59:59" ;
4444 uint minWaitTimeInSeconds = 3600 ; // 1 hour
@@ -47,8 +47,9 @@ int main(string[] args)
4747
4848 try
4949 {
50+ arraySep = " ," ;
5051 args.getopt(
51- getOptConfig.required, " url " , &url ,
52+ getOptConfig.required, " urls " , &urls ,
5253 " start-time" , &startTime,
5354 " end-time" , &endTime,
5455 " min-wait-time" , &minWaitTimeInSeconds,
@@ -61,9 +62,10 @@ int main(string[] args)
6162
6263 setLogLevel(logLevel);
6364
65+
6466 executeAtRandomIntervals(
6567 Params(
66- url: url ,
68+ urls: urls ,
6769 startTime: TimeOfDay .fromISOExtString(startTime),
6870 endTime: TimeOfDay .fromISOExtString(endTime),
6971 minWaitTime: minWaitTimeInSeconds.seconds(),
@@ -99,9 +101,12 @@ void executeAtRandomIntervals(Params params)
99101
100102 if (currentTimeTOD >= startTime && currentTimeTOD <= endTime)
101103 {
102- infof(" Posting alert... " );
103- postAlert(url, alertDuration);
104- infof(" Alert posted successfully." );
104+ foreach (url; urls)
105+ {
106+ infof(" Posting alert on %s..." , url);
107+ postAlert(url, alertDuration);
108+ infof(" Alert posted successfully." );
109+ }
105110 }
106111 else
107112 {
0 commit comments