diff options
author | Mateusz Czapliński <czapkofan@gmail.com> | 2018-03-04 16:36:10 +0100 |
---|---|---|
committer | Mateusz Czapliński <czapkofan@gmail.com> | 2018-03-04 16:36:10 +0100 |
commit | 6b1f150971241f513e3861c2ecb5ceb2397fcf89 (patch) | |
tree | d18185935dc52dead8a7783505b98b0772aaa4dc /up.go | |
parent | 069a0c0bef5851bfcb604a7014e10ef462591915 (diff) |
check if stdin is a tty
Diffstat (limited to 'up.go')
-rw-r--r-- | up.go | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -3,10 +3,12 @@ package main import ( + "fmt" "io" "os" termbox "github.com/akavel/termbox-go" + "github.com/mattn/go-isatty" ) const ( @@ -15,7 +17,14 @@ const ( ) func main() { + // TODO: Without below block, we'd hang with no piped input (see github.com/peco/peco, mattn/gof, fzf, etc.) + if isatty.IsTerminal(os.Stdin.Fd()) { + fmt.Fprintln(os.Stderr, "error: up requires some data piped on standard input, e.g.: `echo hello world | up`") + os.Exit(1) + } + // Init TUI code + // TODO: maybe try gocui or tcell? err := termbox.Init() if err != nil { panic(err) |