Skip to content

Standardize pager output across commands#5141

Merged
samcoe merged 1 commit intotrunkfrom
pager-fixes
Feb 1, 2022
Merged

Standardize pager output across commands#5141
samcoe merged 1 commit intotrunkfrom
pager-fixes

Conversation

@mislav
Copy link
Contributor

@mislav mislav commented Jan 31, 2022

Add pager functionality to the following commands:

  • gist list
  • pr checks
  • release list
  • run list
  • run view
  • secret list
  • workflow list
  • workflow view

Additionally, normalize error handling when starting the pager has failed: only print a non-fatal notice to stderr instead of aborting the whole command.

Fixes #5102

Add pager functionality to the following commands:
- gist list
- pr checks
- release list
- run list
- run view
- secret list
- workflow list
- workflow view

Additionally, normalize error handling when starting the pager has
failed: only print a non-fatal notice to stderr instead of aborting the
whole command.
@mislav mislav requested a review from a team as a code owner January 31, 2022 12:37
@mislav mislav requested review from samcoe and removed request for a team January 31, 2022 12:37
Copy link
Contributor

@samcoe samcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. Thanks for making this behavior consistent! I left a couple non-blocking comments.

}
}

if err := opts.IO.StartPager(); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does a pager interpret/interact with the progress indicator? I think the pager was started in this command explicitly after the progress indicator, but I don't actually know if they conflict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! In my testing it's fine if the progress indicator continues to spin even after the pager has started, but ideally it should never be started after the first output has been written to stdout.

if s, ok := err.(api.HTTPError); ok && s.StatusCode == 404 {
if opts.Ref != "" {
return fmt.Errorf("could not find workflow file %s on %s, try specifying a different ref", workflow.Base(), opts.Ref)
if ref != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to explicitly pass in ref here? Seems like we are still passing in opts.

Copy link
Contributor Author

@mislav mislav Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a valid observation, but I felt it was much more clear for the signature of the method to receive the ref as argument rather than inferring it from opts. Furthermore, I feel like having too many methods having opts as a receiver or argument is an antipattern because it dis-incentivizes the method from having a very limited responsibility. This small refactoring was a step towards not passing opts as an argument in the future.

@samcoe samcoe merged commit 4a3ef50 into trunk Feb 1, 2022
@samcoe samcoe deleted the pager-fixes branch February 1, 2022 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show PR checks summary after checks statuses

2 participants