diff --git a/cmd/cli/commands/config/config_network.go b/cmd/cli/commands/config/config_network.go index 553b24b..2f1d0ce 100644 --- a/cmd/cli/commands/config/config_network.go +++ b/cmd/cli/commands/config/config_network.go @@ -66,6 +66,7 @@ func (p *NetworkConfigPage) initPage() { // Grab the available networks and their descriptions. networks := make([]string, len(tui.AvailableNetworks)) networkDescriptions := make(map[string]string) + for i, network := range tui.AvailableNetworks { networks[i] = network.Value networkDescriptions[network.Value] = network.Description @@ -90,8 +91,10 @@ func (p *NetworkConfigPage) initPage() { switch event.Key() { case tcell.KeyTab, tcell.KeyBacktab: p.display.app.SetFocus(form) + return nil } + return event }) @@ -105,6 +108,7 @@ func (p *NetworkConfigPage) initPage() { // If we're on the last form item, move to save button. if formIndex == form.GetFormItemCount()-1 { p.display.app.SetFocus(saveButton) + return nil } @@ -113,6 +117,7 @@ func (p *NetworkConfigPage) initPage() { // If we're on the first form item, move to save button. if formIndex == 0 { p.display.app.SetFocus(saveButton) + return nil } diff --git a/cmd/cli/commands/config/config_output_server.go b/cmd/cli/commands/config/config_output_server.go index aa7f0ab..a2c180f 100644 --- a/cmd/cli/commands/config/config_output_server.go +++ b/cmd/cli/commands/config/config_output_server.go @@ -92,6 +92,7 @@ func (p *OutputServerConfigPage) initPage() { for i, server := range tui.AvailableOutputServers { if server.Label == "Custom" { defaultIndex = i + break } } @@ -100,6 +101,7 @@ func (p *OutputServerConfigPage) initPage() { for i, server := range tui.AvailableOutputServers { if server.Value == currentAddress { defaultIndex = i + break } } @@ -160,8 +162,10 @@ func (p *OutputServerConfigPage) initPage() { switch event.Key() { case tcell.KeyTab, tcell.KeyBacktab: p.display.app.SetFocus(form) + return nil } + return event }) @@ -175,6 +179,7 @@ func (p *OutputServerConfigPage) initPage() { // If we're on the last form item, move to save button if formIndex == form.GetFormItemCount()-1 { p.display.app.SetFocus(saveButton) + return nil } @@ -183,6 +188,7 @@ func (p *OutputServerConfigPage) initPage() { // If we're on the first form item, move to save button if formIndex == 0 { p.display.app.SetFocus(saveButton) + return nil } @@ -227,7 +233,7 @@ func (p *OutputServerConfigPage) initPage() { func validateAndUpdateOutputServer(p *OutputServerConfigPage) { // Get the currently selected server. - dropdown := p.form.GetFormItem(0).(*tview.DropDown) + dropdown, _ := p.form.GetFormItem(0).(*tview.DropDown) _, serverLabel := dropdown.GetCurrentOption() // Find the corresponding URL @@ -236,6 +242,7 @@ func validateAndUpdateOutputServer(p *OutputServerConfigPage) { for _, server := range tui.AvailableOutputServers { if server.Label == serverLabel { serverAddress = server.Value + break } } @@ -253,7 +260,9 @@ func validateAndUpdateOutputServer(p *OutputServerConfigPage) { p.display.app.SetFocus(p.form) }, ) + p.display.app.SetRoot(errorModal, true) + return } @@ -267,7 +276,9 @@ func validateAndUpdateOutputServer(p *OutputServerConfigPage) { p.display.app.SetFocus(p.form) }, ) + p.display.app.SetRoot(errorModal, true) + return } @@ -313,8 +324,8 @@ func validateAndUpdateOutputServer(p *OutputServerConfigPage) { } else { // Get and validate credentials, these are required for ethPandaOps servers. var ( - username = p.form.GetFormItem(1).(*tview.InputField) - password = p.form.GetFormItem(2).(*tview.InputField) + username, _ = p.form.GetFormItem(1).(*tview.InputField) + password, _ = p.form.GetFormItem(2).(*tview.InputField) usernameText = username.GetText() passwordText = password.GetText() ) @@ -328,7 +339,9 @@ func validateAndUpdateOutputServer(p *OutputServerConfigPage) { p.display.app.SetFocus(p.form) }, ) + p.display.app.SetRoot(errorModal, true) + return } diff --git a/cmd/cli/commands/config/display.go b/cmd/cli/commands/config/display.go index d267045..b8d85d4 100644 --- a/cmd/cli/commands/config/display.go +++ b/cmd/cli/commands/config/display.go @@ -146,8 +146,10 @@ func (d *ConfigDisplay) initPage() { switch event.Key() { case tcell.KeyTab, tcell.KeyBacktab: d.app.SetFocus(d.closeButton) + return nil } + return event }) @@ -181,11 +183,14 @@ func (d *ConfigDisplay) initPage() { switch event.Key() { case tcell.KeyTab, tcell.KeyBacktab: d.app.SetFocus(d.categoryList) + return nil case tcell.KeyUp, tcell.KeyDown: d.app.SetFocus(d.categoryList) + return event } + return event }) diff --git a/cmd/cli/commands/install/display.go b/cmd/cli/commands/install/display.go index ca77a93..fe077ff 100644 --- a/cmd/cli/commands/install/display.go +++ b/cmd/cli/commands/install/display.go @@ -95,6 +95,7 @@ func (d *InstallDisplay) getCurrentStep() int { if step, exists := stepMap[currentPage]; exists { return step } + return 1 } diff --git a/cmd/cli/commands/install/page_20_network.go b/cmd/cli/commands/install/page_20_network.go index bde6c0a..5704ae4 100644 --- a/cmd/cli/commands/install/page_20_network.go +++ b/cmd/cli/commands/install/page_20_network.go @@ -132,8 +132,10 @@ func (p *NetworkConfigPage) initPage() { if p.page.Parent != nil { p.display.setPage(p.page.Parent) } + return nil } + return event }) diff --git a/cmd/cli/commands/install/page_30_beacon_node.go b/cmd/cli/commands/install/page_30_beacon_node.go index 063fc7e..401dca4 100644 --- a/cmd/cli/commands/install/page_30_beacon_node.go +++ b/cmd/cli/commands/install/page_30_beacon_node.go @@ -157,7 +157,9 @@ func validateAndUpdate(p *BeaconNodePage) { p.display.app.SetFocus(p.form) }, ) + p.display.app.SetRoot(errorModal, true) + return } @@ -175,7 +177,7 @@ func validateAndUpdate(p *BeaconNodePage) { func validateBeaconNode(address string) error { // Check if URL is valid if !strings.HasPrefix(address, "http://") && !strings.HasPrefix(address, "https://") { - return fmt.Errorf("Beacon node address must start with http:// or https://") + return fmt.Errorf("beacon node address must start with http:// or https://") } // Try to connect to the beacon node @@ -183,13 +185,13 @@ func validateBeaconNode(address string) error { resp, err := client.Get(fmt.Sprintf("%s/eth/v1/node/health", address)) if err != nil { - return fmt.Errorf("We're unable to connect to your beacon node: %w", err) + return fmt.Errorf("we're unable to connect to your beacon node: %w", err) } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("Beacon node returned status %d", resp.StatusCode) + return fmt.Errorf("beacon node returned status %d", resp.StatusCode) } return nil diff --git a/cmd/cli/commands/install/page_40_output_server.go b/cmd/cli/commands/install/page_40_output_server.go index b4461f3..8ed6530 100644 --- a/cmd/cli/commands/install/page_40_output_server.go +++ b/cmd/cli/commands/install/page_40_output_server.go @@ -149,7 +149,9 @@ func (p *OutputServerPage) initPage() { p.display.app.SetFocus(form) }, ) + p.display.app.SetRoot(errorModal, true) + return } @@ -163,7 +165,9 @@ func (p *OutputServerPage) initPage() { p.display.app.SetFocus(form) }, ) + p.display.app.SetRoot(errorModal, true) + return } } diff --git a/cmd/cli/commands/install/page_50_output_server_credentials.go b/cmd/cli/commands/install/page_50_output_server_credentials.go index 54ac0cf..b971e17 100644 --- a/cmd/cli/commands/install/page_50_output_server_credentials.go +++ b/cmd/cli/commands/install/page_50_output_server_credentials.go @@ -96,7 +96,9 @@ func (p *OutputServerCredentialsPage) initPage() { p.display.app.SetFocus(form) }, ) + p.display.app.SetRoot(errorModal, true) + return } } @@ -173,7 +175,9 @@ func validateAndSaveCredentials(p *OutputServerCredentialsPage) { p.display.app.SetFocus(p.form) }, ) + p.display.app.SetRoot(errorModal, true) + return } } diff --git a/cmd/cli/commands/update/update.go b/cmd/cli/commands/update/update.go index 021efa8..fc17ca4 100644 --- a/cmd/cli/commands/update/update.go +++ b/cmd/cli/commands/update/update.go @@ -54,6 +54,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { cfg.Version = currentVersion }); err != nil { log.Errorf("Failed to roll back version in config: %v", err) + return } @@ -125,6 +126,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { // Save the updated config. if err := configService.Save(); err != nil { log.Errorf("could not save updated config: %v", err) + return err } @@ -134,6 +136,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { dockerService, err := service.NewDockerService(log, configService) if err != nil { log.Errorf("could not create docker service: %v", err) + return err } @@ -141,6 +144,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { if e := dockerService.Update(); e != nil { log.Errorf("could not update service: %v", e) + return e } @@ -148,6 +152,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { running, err := dockerService.IsRunning() if err != nil { log.Errorf("could not check service status: %v", err) + return err } @@ -184,6 +189,7 @@ func updateContributoor(c *cli.Context, opts *options.CommandOpts) error { running, err := binaryService.IsRunning() if err != nil { log.Errorf("could not check service status: %v", err) + return err } diff --git a/cmd/cli/options/command.go b/cmd/cli/options/command.go index f6d935b..418355f 100644 --- a/cmd/cli/options/command.go +++ b/cmd/cli/options/command.go @@ -17,6 +17,7 @@ func NewCommandOpts(opts ...CommandOptFunc) *CommandOpts { for _, opt := range opts { opt(options) } + return options } diff --git a/internal/tui/frame.go b/internal/tui/frame.go index cb66c56..8c12aa6 100644 --- a/internal/tui/frame.go +++ b/internal/tui/frame.go @@ -51,8 +51,10 @@ func CreatePageFrame(opts PageFrameOptions) *tview.Frame { frame.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyEsc { opts.OnEsc() + return nil } + return event }) }