gracefully exit when no tty is present; partially addresses #253

This commit is contained in:
Alex Goodman 2019-11-21 20:45:35 -08:00
commit a26de0ed45
No known key found for this signature in database
GPG key ID: 150587AB82D3C4E6

View file

@ -1,8 +1,11 @@
package ui
import (
"fmt"
"github.com/wagoodman/dive/dive/image"
"github.com/wagoodman/dive/runtime/ui/key"
"golang.org/x/crypto/ssh/terminal"
"os"
"sync"
"github.com/jroimartin/gocui"
@ -121,6 +124,10 @@ func (a *app) quit() error {
func Run(analysis *image.AnalysisResult, treeStack filetree.Comparer) error {
var err error
if !terminal.IsTerminal(int(os.Stdout.Fd())) {
return fmt.Errorf("no tty present, refusing show ui (if running in docker, use -it args)")
}
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
return err