Skip to content

Commit 3f410c8

Browse files
committed
Print usage when not spec is provided
1 parent a126391 commit 3f410c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"syscall"
1111
"time"
1212

13+
"github.com/monochromegane/terminal"
1314
"github.com/rs/jplot/data"
1415
"github.com/rs/jplot/graph"
1516
"github.com/rs/jplot/osc"
@@ -44,15 +45,22 @@ func main() {
4445
fatal("screen and tmux not supported")
4546
}
4647

48+
if len(flag.Args()) == 0 {
49+
flag.Usage()
50+
os.Exit(1)
51+
}
52+
4753
specs, err := data.ParseSpec(flag.Args())
4854
if err != nil {
4955
fatal("Cannot parse spec: ", err)
5056
}
5157
var dp *data.Points
5258
if *url != "" {
5359
dp = data.FromHTTP(*url, *interval, *steps)
54-
} else {
60+
} else if !terminal.IsTerminal(os.Stdin) {
5561
dp = data.FromStdin(*steps)
62+
} else {
63+
fatal("neither --url nor stdin is provided")
5664
}
5765
dash := graph.Dash{
5866
Specs: specs,

0 commit comments

Comments
 (0)