From cfa275152c67fdaa854bf1dfb5ff317494c19ecb Mon Sep 17 00:00:00 2001 From: Michael Fridman Date: Fri, 19 Oct 2018 00:39:22 -0400 Subject: [PATCH] Fixes named pipe bug with flags; updates readme usage --- README.md | 4 ++-- main.go | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 49797b2..0dbdb4e 100644 --- a/README.md +++ b/README.md @@ -17,12 +17,12 @@ Once `tparse` is installed there are 2 ways to use it: Example: ``` -go test fmt -json | tparse +go test fmt -json | tparse -all ``` 2. Save the output of `go test` with the `-json` flag into a file and call `tparse` with filename as an argument. ``` go test fmt -json > fmt.out -tparse fmt.out +tparse -all fmt.out ``` \ No newline at end of file diff --git a/main.go b/main.go index 150bc3a..9008508 100644 --- a/main.go +++ b/main.go @@ -137,7 +137,7 @@ func main() { // read from a named pipe (no args) or from single arg expected to be a faile path func getReader() (io.Reader, error) { - switch len(os.Args[1:]) { + switch flag.NArg() { case 0: // Get FileInfo interface and fail everything except a named pipe (FIFO). finfo, err := os.Stdin.Stat() @@ -159,11 +159,6 @@ func getReader() (io.Reader, error) { default: // Attempt to read from a file. - // After processing all flags, we should have one file to read from, fail otherwise. - if flag.NArg() < 1 { - flag.Usage() - } - dat, err := ioutil.ReadFile(os.Args[len(os.Args)-flag.NArg()]) // 🦄 if err != nil { return nil, err