Skip to content

Commit

Permalink
feat(cmd): Do not use pager renderer if not needed
Browse files Browse the repository at this point in the history
Signed-off-by: Cezar Craciunoiu <[email protected]>
  • Loading branch information
craciunoiuc committed Dec 12, 2023
1 parent c8885c8 commit 9424d4d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/governctl/pr/check/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,22 @@ func (opts *Patch) Run(cmd *cobra.Command, args []string) error {
os.RemoveAll(pull.Workdir())
}

err = iostreams.G(ctx).StartPager()
if err != nil {
log.G(ctx).Errorf("error starting pager: %v", err)
}
if !kitcfg.G[config.Config](ctx).NoRender {
err = iostreams.G(ctx).StartPager()
if err != nil {
log.G(ctx).Errorf("error starting pager: %v", err)
}

defer iostreams.G(ctx).StopPager()
defer iostreams.G(ctx).StopPager()
}

err = table.Render(iostreams.G(ctx).Out)
if err != nil {
return err
}

if errors > 0 || warnings > 0 {
return fmt.Errorf("checkpatch failed with %d errors and %d warnings", errors, warnings)
return fmt.Errorf("summary: checkpatch failed with %d errors and %d warnings", errors, warnings)
}

return nil
Expand Down

0 comments on commit 9424d4d

Please sign in to comment.