diff options
author | Maas Lalani <maas@lalani.dev> | 2022-12-13 15:46:43 -0500 |
---|---|---|
committer | Maas Lalani <maas@lalani.dev> | 2022-12-13 15:47:32 -0500 |
commit | 832c4fc917a0d247a65887940117ba848ad474f5 (patch) | |
tree | d03eb02e9855bc02fb3318721a7f79fc4cba097a | |
parent | c8e6b4a9d5aa4c7a8d8018584d32bfde45c1dbdf (diff) |
feat: ctrl+c / esc aborts actionv0.9.0
-rw-r--r-- | confirm/command.go | 4 | ||||
-rw-r--r-- | confirm/confirm.go | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/confirm/command.go b/confirm/command.go index ef8cf6e..92a55ed 100644 --- a/confirm/command.go +++ b/confirm/command.go @@ -29,7 +29,9 @@ func (o Options) Run() error { return fmt.Errorf("unable to run confirm: %w", err) } - if m.(model).confirmation { + if m.(model).aborted { + os.Exit(130) + } else if m.(model).confirmation { os.Exit(0) } else { os.Exit(1) diff --git a/confirm/confirm.go b/confirm/confirm.go index 94c4819..b532e52 100644 --- a/confirm/confirm.go +++ b/confirm/confirm.go @@ -23,6 +23,7 @@ type model struct { affirmative string negative string quitting bool + aborted bool hasTimeout bool timeout time.Duration @@ -57,7 +58,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil case tea.KeyMsg: switch msg.String() { - case "ctrl+c", "esc", "q", "n", "N": + case "ctrl+c", "esc": + m.confirmation = false + m.aborted = true + m.quitting = true + return m, tea.Quit + case "q", "n", "N": m.confirmation = false m.quitting = true return m, tea.Quit |