Skip to content

Commit

Permalink
Print usage when not spec is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
rs committed Mar 12, 2018
1 parent a126391 commit 3f410c8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion main.go
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"
"time"

"github.com/monochromegane/terminal"
"github.com/rs/jplot/data"
"github.com/rs/jplot/graph"
"github.com/rs/jplot/osc"
Expand Down Expand Up @@ -44,15 +45,22 @@ func main() {
fatal("screen and tmux not supported")
}

if len(flag.Args()) == 0 {
flag.Usage()
os.Exit(1)
}

specs, err := data.ParseSpec(flag.Args())
if err != nil {
fatal("Cannot parse spec: ", err)
}
var dp *data.Points
if *url != "" {
dp = data.FromHTTP(*url, *interval, *steps)
} else {
} else if !terminal.IsTerminal(os.Stdin) {
dp = data.FromStdin(*steps)
} else {
fatal("neither --url nor stdin is provided")
}
dash := graph.Dash{
Specs: specs,
Expand Down

0 comments on commit 3f410c8

Please sign in to comment.