dive-zfs/utils/exit.go
Christian Muehlhaeuser 57b1a3d522
Fixed import order using goimports
Probably just prevents future merge conflicts.
2019-07-19 12:44:16 +02:00

35 lines
438 B
Go

package utils
import (
"fmt"
"os"
"github.com/jroimartin/gocui"
"github.com/sirupsen/logrus"
)
var ui *gocui.Gui
func SetUi(g *gocui.Gui) {
ui = g
}
func PrintAndExit(args ...interface{}) {
logrus.Println(args...)
Cleanup()
fmt.Println(args...)
os.Exit(1)
}
// Note: this should only be used when exiting from non-gocui code
func Exit(rc int) {
Cleanup()
os.Exit(rc)
}
func Cleanup() {
if ui != nil {
ui.Close()
}
}