Skip to content

Commit 9cde4b1

Browse files
committed
add ctrl + c to exit the app
1 parent 5e37993 commit 9cde4b1

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pkg/tui/tui_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ Host srv-2
6060
assert.Equal(t, ModeCommand, m.Mode)
6161
assert.True(t, m.CommandInput.Focused())
6262
})
63+
64+
t.Run("global ctrl+c exit", func(t *testing.T) {
65+
_, cmd := m.Update(tea.KeyMsg{Type: tea.KeyCtrlC})
66+
assert.NotNil(t, cmd)
67+
msg := cmd()
68+
_, isQuit := msg.(tea.QuitMsg)
69+
assert.True(t, isQuit)
70+
})
6371
}
6472

6573
// TestTUICommandExec tests command mode execution parsing.

pkg/tui/update.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
4343
return m, nil
4444

4545
case tea.KeyMsg:
46+
if msg.Type == tea.KeyCtrlC {
47+
return m, tea.Quit
48+
}
4649
// Reset temporary notifications on keypress
4750
m.AlertText = ""
4851
m.ErrorText = ""

0 commit comments

Comments
 (0)