diff --git a/cmd/openqa-revtui/openqa-revtui.go b/cmd/openqa-revtui/openqa-revtui.go index 65d15d3..64966e9 100644 --- a/cmd/openqa-revtui/openqa-revtui.go +++ b/cmd/openqa-revtui/openqa-revtui.go @@ -163,15 +163,15 @@ func registerRabbitMQ(cf *Config, remote, topic string) (gopenqa.RabbitMQ, error } func main() { - var cf Config + var defaultConfig Config var err error cfs = make([]Config, 0) - if cf, err = loadDefaultConfig(); err != nil { + if defaultConfig, err = loadDefaultConfig(); err != nil { fmt.Fprintf(os.Stderr, "Error loading default config file: %s\n", err) os.Exit(1) } - if err := parseProgramArgs(&cf); err != nil { + if err := parseProgramArgs(&defaultConfig); err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) } @@ -179,13 +179,15 @@ func main() { // If no configuration file has been added, use the default configuration // This is needed for allowing configuration to be set via program parameters if len(cfs) < 1 { - cfs = append(cfs, cf) - if err := cf.Validate(); err != nil { + if err := defaultConfig.Validate(); err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) } + cfs = append(cfs, defaultConfig) } + cf := &cfs[cfi] + // Run TUI and use the return code tui = CreateTUI() // Apply sorting of the first group diff --git a/cmd/openqa-revtui/tui.go b/cmd/openqa-revtui/tui.go index 37075f9..7186f28 100644 --- a/cmd/openqa-revtui/tui.go +++ b/cmd/openqa-revtui/tui.go @@ -231,19 +231,23 @@ func (tui *TUI) readInput() { // Always leave one line overlap for better orientation tui.Model.offset = min(max, tui.Model.offset+tui.screensize-1) case 90: // Shift+Tab - cfi-- - if cfi < 0 { - cfi = len(cfs) - 1 + if len(cfs) > 1 { + cfi-- + if cfi < 0 { + cfi = len(cfs) - 1 + } + RefreshJobs() + tui.Update() } - RefreshJobs() - tui.Update() } } // Default keys if k == 9 { // Tab - cfi = (cfi + 1) % len(cfs) - RefreshJobs() - tui.Update() + if len(cfs) > 1 { + cfi = (cfi + 1) % len(cfs) + RefreshJobs() + tui.Update() + } } // Forward keypress to listener