Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spinner): abstract common pattern #1024

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

Integralist
Copy link
Collaborator

@Integralist Integralist commented Sep 29, 2023

There's a common pattern used across the CLI where we...

  • Start a spinner.
  • Start doing some processing.
  • Stop the spinner...
    • Because of an error.
    • Because we're finished.

It's very tedious and verbose/noisy code and makes reading the code quite hard at times.

So I've made an abstraction to try and reduce the noise.

The spinner abstraction can be seen in pkg/text/spinner.go.

@Integralist Integralist added the enhancement New feature or request label Sep 29, 2023
Copy link
Collaborator

@awilliams-fastly awilliams-fastly left a comment

Choose a reason for hiding this comment

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

Nice! This really removes a lot of boilerplate.

I reviewed the changes where the SpinnerWrapper is used, but mainly focused on the implementation. Left a few minor comments, but looking good in general.

pkg/text/spinner.go Show resolved Hide resolved
pkg/text/spinner.go Outdated Show resolved Hide resolved
@Integralist Integralist force-pushed the integralist/abstract-spinner branch from 91f8a5b to 7ba5b64 Compare October 2, 2023 09:26
@Integralist Integralist merged commit cee7784 into main Oct 2, 2023
6 checks passed
@Integralist Integralist deleted the integralist/abstract-spinner branch October 2, 2023 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants