mirror of
https://github.com/charmbracelet/gum
synced 2024-06-13 03:02:24 +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.
|
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
|
```bash
|
||||||
gum write > story.txt
|
gum write > story.txt
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/charmbracelet/bubbles/filepicker"
|
"github.com/charmbracelet/bubbles/filepicker"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
|
"github.com/charmbracelet/gum/internal/exit"
|
||||||
"github.com/charmbracelet/gum/style"
|
"github.com/charmbracelet/gum/style"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,6 +54,9 @@ func (o Options) Run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
m = tm.(model)
|
m = tm.(model)
|
||||||
|
if m.aborted {
|
||||||
|
return exit.ErrAborted
|
||||||
|
}
|
||||||
|
|
||||||
if m.selectedPath == "" {
|
if m.selectedPath == "" {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
type model struct {
|
type model struct {
|
||||||
filepicker filepicker.Model
|
filepicker filepicker.Model
|
||||||
selectedPath string
|
selectedPath string
|
||||||
|
aborted bool
|
||||||
quitting bool
|
quitting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +32,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
case "ctrl+c", "q":
|
case "ctrl+c", "q", "esc":
|
||||||
|
m.aborted = true
|
||||||
|
m.quitting = true
|
||||||
return m, tea.Quit
|
return m, tea.Quit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue