Скорректировано поведение --repeat
При значении 0 количество итераций будет бесконечным
This commit is contained in:
16
cmd/check.go
16
cmd/check.go
@@ -35,13 +35,8 @@ var checkCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentIteration := 1
|
currentIteration := 1
|
||||||
iterationCount := app.Args.RepeatCount
|
|
||||||
if iterationCount <= 0 {
|
|
||||||
iterationCount = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if app.Args.RepeatCount > 1 {
|
if app.Args.RepeatCount != 1 {
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"@ New iteration current=%d count=%d\n",
|
"@ New iteration current=%d count=%d\n",
|
||||||
currentIteration,
|
currentIteration,
|
||||||
@@ -65,11 +60,12 @@ var checkCmd = &cobra.Command{
|
|||||||
fmt.Println(string(marshal))
|
fmt.Println(string(marshal))
|
||||||
}
|
}
|
||||||
|
|
||||||
if app.Args.RepeatCount <= 1 || uint(currentIteration) == app.Args.RepeatCount {
|
if app.Args.RepeatCount != 0 {
|
||||||
break
|
if uint(currentIteration) == app.Args.RepeatCount {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
currentIteration++
|
||||||
}
|
}
|
||||||
|
|
||||||
currentIteration++
|
|
||||||
log.Printf("Waiting for new iteration... seconds=%d\n", app.Args.RepeatEverySec)
|
log.Printf("Waiting for new iteration... seconds=%d\n", app.Args.RepeatEverySec)
|
||||||
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
|
time.Sleep(time.Duration(app.Args.RepeatEverySec) * time.Second)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user