Skip to content

Commit

Permalink
tz
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Scherba <mikhail.scherba@flant.com>
  • Loading branch information
miklezzzz committed Jan 20, 2025
1 parent f3519ee commit 2f539ae
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pkg/debug/debug-cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
var (
outputFormat = "text"
showEmpty = false
watchInterval = "0s"
watch = false
watchInterval = "1s"
)

func DefineDebugCommands(kpApp *kingpin.Application) {
Expand All @@ -21,17 +22,22 @@ func DefineDebugCommands(kpApp *kingpin.Application) {

queueListCmd := queueCmd.Command("list", "Dump tasks in all queues.").
Action(func(_ *kingpin.ParseContext) error {
dur, err := time.ParseDuration(watchInterval)
if err != nil {
return fmt.Errorf("couldn't parse watch interval: %w", err)
var dur time.Duration
if watch {
var err error
dur, err = time.ParseDuration(watchInterval)
if err != nil {
return fmt.Errorf("couldn't parse watch refresh interval: %w", err)
}
}
for {
out, err := Queue(DefaultClient()).List(outputFormat, showEmpty)
if err != nil {
return err
}
fmt.Println(string(out))
if dur == 0 {

if !watch {
break
}
time.Sleep(dur)
Expand All @@ -42,6 +48,9 @@ func DefineDebugCommands(kpApp *kingpin.Application) {
Default("false").
BoolVar(&showEmpty)
queueListCmd.Flag("watch", "Keep watching.").Short('w').
Default("false").
BoolVar(&watch)
queueListCmd.Flag("watchInterval", "Watch refresh interval.").Short('t').
Default(watchInterval).
StringVar(&watchInterval)
AddOutputJsonYamlTextFlag(queueListCmd)
Expand Down

0 comments on commit 2f539ae

Please sign in to comment.