replace if-else chaining with switch

master
Joshua Herring 1 month ago
parent b85f78146c
commit 14bdd60969

@ -134,7 +134,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if msg.String() == "enter" {
m.choice = m.list.Index()
m.state = stateForm
if m.choice == 0 {
switch m.choice {
case 0:
m.form = huh.NewForm(
huh.NewGroup(
huh.NewInput().Title("Remote Command").Key("remote_command").Value(&m.RemoteCommand),
@ -143,7 +144,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
huh.NewInput().Title("Host").Key("host").Value(&m.Host),
),
)
} else if m.choice == 1 {
case 1:
m.form = huh.NewForm(
huh.NewGroup(
huh.NewInput().Title("Local Filepath").Key("local_filepath").Value(&m.LocalFilepath),
@ -153,7 +154,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
huh.NewInput().Title("Host").Key("host").Value(&m.Host),
),
)
} else {
default:
m.form = huh.NewForm(
huh.NewGroup(
huh.NewInput().Title("Cloudflare API Token").Key("cloudflare_api_token").Value(&m.CloudflareAPIToken),

Loading…
Cancel
Save