@@ -12,11 +12,14 @@ import (
12
12
"net/url"
13
13
"os"
14
14
"strconv"
15
+ "time"
15
16
)
16
17
17
- var cloudHost string
18
- var cloudPort int
18
+ var cloudHost = "localhost"
19
+ var cloudPort = 9000
19
20
var configFile string
21
+ var cycleRepeat bool
22
+ var cycleLength int64
20
23
21
24
func main () {
22
25
app := cli .NewApp ()
@@ -69,6 +72,28 @@ func main() {
69
72
}},
70
73
Action : click ,
71
74
},
75
+ {
76
+ Name : "cycle" ,
77
+ Usage : "Click each item in the list" ,
78
+ UsageText : "clicker cycle" ,
79
+ Description : "Show model of item." ,
80
+ Flags : []cli.Flag {
81
+ & cli.BoolFlag {
82
+ Name : "repeat" ,
83
+ Value : false ,
84
+ Usage : "Repeat the list" ,
85
+ Aliases : []string {"r" },
86
+ Destination : & cycleRepeat ,
87
+ },
88
+ & cli.Int64Flag {
89
+ Name : "length" ,
90
+ Value : 30 ,
91
+ Usage : "Length in seconds" ,
92
+ Aliases : []string {"l" },
93
+ Destination : & cycleLength ,
94
+ }},
95
+ Action : cycle ,
96
+ },
72
97
}
73
98
74
99
err := app .Run (os .Args )
@@ -182,3 +207,24 @@ func call(item *Item) error {
182
207
}
183
208
return nil
184
209
}
210
+
211
+ func cycle (c * cli.Context ) error {
212
+ cfg , e := parseClickerConf ()
213
+ if e != nil {
214
+ log .Printf ("failed to read clicker configuration" )
215
+ return e
216
+ }
217
+
218
+ for {
219
+ for idx , item := range cfg .Items {
220
+ fmt .Printf ("\t %v. %v\n " , idx + 1 , item .Title )
221
+ e = call (& item )
222
+ time .Sleep (time .Duration (cycleLength ) * time .Second )
223
+ }
224
+ if ! cycleRepeat {
225
+ break
226
+ }
227
+ }
228
+
229
+ return nil
230
+ }
0 commit comments