summaryrefslogtreecommitdiffstats
path: root/up.go
diff options
context:
space:
mode:
authorMateusz Czapliński <czapkofan@gmail.com>2018-03-04 16:36:10 +0100
committerMateusz Czapliński <czapkofan@gmail.com>2018-03-04 16:36:10 +0100
commit6b1f150971241f513e3861c2ecb5ceb2397fcf89 (patch)
treed18185935dc52dead8a7783505b98b0772aaa4dc /up.go
parent069a0c0bef5851bfcb604a7014e10ef462591915 (diff)
check if stdin is a tty
Diffstat (limited to 'up.go')
-rw-r--r--up.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/up.go b/up.go
index 55baa3b..9eba7e0 100644
--- a/up.go
+++ b/up.go
@@ -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)