Skip to content

Commit

Permalink
Default to output directly to terminal if pager output fails
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopalet committed May 6, 2024
1 parent 0b621e4 commit b2b90c7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/pkg/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,15 @@ func (p *Printer) PagerDisplay(content string) error {
if outputFormat == NoneOutputFormat {
return nil
}
lessCmd := exec.Command("less", "-F", "-S", "-w")
lessCmd.Stdin = strings.NewReader(content)
lessCmd.Stdout = p.Cmd.OutOrStdout()
pagerCmd := exec.Command("less", "-F", "-S", "-w")

err := lessCmd.Run()
pagerCmd.Stdin = strings.NewReader(content)
pagerCmd.Stdout = p.Cmd.OutOrStdout()

err := pagerCmd.Run()
if err != nil {
return fmt.Errorf("run less command: %w", err)
p.Debug(ErrorLevel, "run pager command: %v", err)
p.Outputln(content)
}
return nil
}
Expand Down

0 comments on commit b2b90c7

Please sign in to comment.