much better
This commit is contained in:
+14
-1
@@ -2,15 +2,28 @@ package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
tea "charm.land/bubbletea/v2"
|
||||
)
|
||||
|
||||
func Run() error {
|
||||
p := tea.NewProgram(New())
|
||||
_, err := p.Run()
|
||||
m, err := p.Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("tui error: %w", err)
|
||||
}
|
||||
|
||||
if model, ok := m.(Model); ok {
|
||||
if model.command != "" {
|
||||
if model.result.Error != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed: %s\n", model.command)
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", model.result.Error)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stdout, "%s\n", model.command)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user