Skip to content

Commit

Permalink
Fixes named pipe bug with flags; updates readme usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman committed Oct 19, 2018
1 parent 8579f17 commit cfa2751
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit cfa2751

Please sign in to comment.