diff --git a/internal/setup/flag_toggle.go b/internal/setup/flag_toggle.go index dc261452..21d7856b 100644 --- a/internal/setup/flag_toggle.go +++ b/internal/setup/flag_toggle.go @@ -23,7 +23,7 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: switch { - case key.Matches(msg, keys.Enter): + case key.Matches(msg, keys.Toggle): m.enabled = !m.enabled } } @@ -33,13 +33,13 @@ func (m flagToggleModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { func (m flagToggleModel) View() string { var furtherInstructions string - title := "Toggle your feature flag!" + title := "Toggle your feature flag (press tab)" toggle := "OFF" bgColor := "#646a73" margin := 1 if m.enabled { bgColor = "#3d9c51" - furtherInstructions = "\n\nCheck your [browser|application logs] to see the change." + furtherInstructions = "\n\nCheck your [browser|application logs] to see the change!" margin = 2 toggle = "ON" } diff --git a/internal/setup/wizard.go b/internal/setup/wizard.go index cc9e211d..868d0f01 100644 --- a/internal/setup/wizard.go +++ b/internal/setup/wizard.go @@ -5,6 +5,7 @@ import ( "github.com/charmbracelet/bubbles/key" tea "github.com/charmbracelet/bubbletea" + "github.com/muesli/reflow/wordwrap" ) // TODO: we may want to rename this for clarity @@ -102,7 +103,10 @@ func (m WizardModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case flagToggleStep: updatedModel, _ := m.steps[flagToggleStep].Update(msg) m.steps[flagToggleStep] = updatedModel + m.currStep += 1 default: + return m, tea.Quit + } case key.Matches(msg, keys.Back): // only go back if not on the first step @@ -130,14 +134,19 @@ func (m WizardModel) View() string { return fmt.Sprintf("ERROR: %s", m.err) } + if m.currStep > flagToggleStep { + return wordwrap.String("\nCongratulations! You’ve just used feature flags to control how your application works, without having to rebuild or redeploy your application.\n\nNow that you’re set up with your first feature flag, let’s make it easier to manage your flags collaboratively with your team. ", m.width) + } + return fmt.Sprintf("\nStep %d of %d\n"+m.steps[m.currStep].View(), m.currStep+1, len(m.steps)) } type keyMap struct { - Back key.Binding - Enter key.Binding - Help key.Binding - Quit key.Binding + Back key.Binding + Enter key.Binding + Help key.Binding + Quit key.Binding + Toggle key.Binding } var keys = keyMap{ @@ -157,4 +166,8 @@ var keys = keyMap{ key.WithKeys("ctrl+c", "q"), key.WithHelp("q", "quit"), ), + Toggle: key.NewBinding( + key.WithKeys("tab"), + key.WithHelp("tab", "toggle"), + ), }