mirror of
https://github.com/charmbracelet/gum
synced 2024-06-08 08:42:16 +02:00
Compare commits
2 commits
97feb1b4d0
...
38521ff870
Author | SHA1 | Date | |
---|---|---|---|
38521ff870 | |||
d9a3dc5324 |
|
@ -197,7 +197,7 @@ gum input --password > password.txt
|
|||
|
||||
Prompt for some multi-line text.
|
||||
|
||||
Note: `CTRL+D` and `esc` are used to complete text entry. `CTRL+C` will cancel.
|
||||
Note: `CTRL+D` is used to complete text entry. `CTRL+C` and `esc` will cancel.
|
||||
|
||||
```bash
|
||||
gum write > story.txt
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/alecthomas/kong"
|
||||
"github.com/charmbracelet/bubbles/filepicker"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/gum/internal/exit"
|
||||
"github.com/charmbracelet/gum/style"
|
||||
)
|
||||
|
||||
|
@ -53,6 +54,9 @@ func (o Options) Run() error {
|
|||
}
|
||||
|
||||
m = tm.(model)
|
||||
if m.aborted {
|
||||
return exit.ErrAborted
|
||||
}
|
||||
|
||||
if m.selectedPath == "" {
|
||||
os.Exit(1)
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
type model struct {
|
||||
filepicker filepicker.Model
|
||||
selectedPath string
|
||||
aborted bool
|
||||
quitting bool
|
||||
}
|
||||
|
||||
|
@ -31,7 +32,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
switch msg := msg.(type) {
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "ctrl+c", "q":
|
||||
case "ctrl+c", "q", "esc":
|
||||
m.aborted = true
|
||||
m.quitting = true
|
||||
return m, tea.Quit
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue