Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 44 additions & 38 deletions cmd/catp/catp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,39 @@
}
}

var files []string

args := flag.Args()
isStdin := false

if len(args) == 1 && args[0] == "-" {
files = append(files, "-") // STDIN
isStdin = true
} else {

Check notice on line 561 in cmd/catp/catp/app.go

View workflow job for this annotation

GitHub Actions / test (stable)

2 statement(s) on lines 558:561 are not covered by tests.
for _, f := range args {
glob, err := filepath.Glob(f)
if err != nil {
return err
}

Check notice on line 566 in cmd/catp/catp/app.go

View workflow job for this annotation

GitHub Actions / test (stable)

1 statement(s) on lines 564:566 are not covered by tests.

for _, f := range glob {
alreadyThere := false

for _, e := range files {
if e == f {
alreadyThere = true

break

Check notice on line 575 in cmd/catp/catp/app.go

View workflow job for this annotation

GitHub Actions / test (stable)

3 statement(s) on lines 571:575 are not covered by tests.
}
}

if !alreadyThere {
files = append(files, f)
}
}
}
}

if *output != "" && r.outDir == "" { //nolint:nestif
fn := *output

Expand Down Expand Up @@ -595,14 +628,18 @@
}
}()
} else {
w := bufio.NewWriterSize(os.Stdout, 64*1024)
r.output = w
if isStdin {
r.output = os.Stdout
} else {
w := bufio.NewWriterSize(os.Stdout, 64*1024)
r.output = w

Check notice on line 635 in cmd/catp/catp/app.go

View workflow job for this annotation

GitHub Actions / test (stable)

10 statement(s) on lines 630:638 are not covered by tests.

defer func() {
if err := w.Flush(); err != nil {
log.Fatalf("failed to flush STDOUT buffer: %s", err)
}
}()
defer func() {
if err := w.Flush(); err != nil {
log.Fatalf("failed to flush STDOUT buffer: %s", err)
}

Check notice on line 640 in cmd/catp/catp/app.go

View workflow job for this annotation

GitHub Actions / test (stable)

6 statement(s) on lines 633:640 are not covered by tests.
}()
}
}

if len(pass) > 0 {
Expand Down Expand Up @@ -643,37 +680,6 @@
},
}

var files []string

args := flag.Args()

if len(args) == 1 && args[0] == "-" {
files = append(files, "-") // STDIN
} else {
for _, f := range args {
glob, err := filepath.Glob(f)
if err != nil {
return err
}

for _, f := range glob {
alreadyThere := false

for _, e := range files {
if e == f {
alreadyThere = true

break
}
}

if !alreadyThere {
files = append(files, f)
}
}
}
}

for _, fn := range files {
if fn == "-" {
r.totalBytes = -1
Expand Down
Loading