refactor: exit package

This commit is contained in:
Maas Lalani 2022-07-30 21:21:00 -04:00
parent 6538d726d1
commit d324abeab5
2 changed files with 6 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/alecthomas/kong"
"github.com/charmbracelet/bubbles/textinput"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/gum/internal/exit"
"github.com/charmbracelet/gum/internal/files"
"github.com/charmbracelet/gum/internal/stdin"
"github.com/charmbracelet/gum/style"
@ -45,7 +46,7 @@ func (o Options) Run() error {
m := tm.(model)
if m.aborted {
return fmt.Errorf("filter aborted")
os.Exit(exit.Aborted)
}
if len(m.matches) > m.selected && m.selected >= 0 {
fmt.Println(m.matches[m.selected].Str)

4
internal/exit/exit.go Normal file
View File

@ -0,0 +1,4 @@
package exit
// Aborted is the exit code for aborted commands.
const Aborted = 130