-
Notifications
You must be signed in to change notification settings - Fork 282
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
New spinner with option #148
New spinner with option #148
Conversation
Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
This doesn't break existing code as it uses variadic arguments, so any existing code as the following should continue to work: s := spinner.New() s.spinner = spinner.Dot This change allows for instead of those two lines, having a call: s := spinner.New(spinner.WithSpinner(spinner.Dot)) Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
Signed-off-by: Leandro López (inkel) <[email protected]>
Any updates on this? It'd be nice to at least have the CI checks feedback 😬 |
We'll review this as soon as possible, just a bit more patience, please 🙂 |
Hey @inkel, this looks great. Thank you for adding docs/comments and tests! |
Thank you @maaslalani !!! Your decision of removing the specific spinners makes total sense, good call! |
…e` options (#148) * Add spinner.New test Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.Option type and spinner.WithSpinner option Signed-off-by: Leandro López (inkel) <[email protected]> * Allow passing options in spinner.New This doesn't break existing code as it uses variadic arguments, so any existing code as the following should continue to work: s := spinner.New() s.spinner = spinner.Dot This change allows for instead of those two lines, having a call: s := spinner.New(spinner.WithSpinner(spinner.Dot)) Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.WithX option for each spinner.Spinner Signed-off-by: Leandro López (inkel) <[email protected]> * Refactor spinner tests Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.WithStyle option function Signed-off-by: Leandro López (inkel) <[email protected]> * refactor: remove With... Spinner aliases Co-authored-by: Maas Lalani <[email protected]>
…e` options (charmbracelet#148) * Add spinner.New test Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.Option type and spinner.WithSpinner option Signed-off-by: Leandro López (inkel) <[email protected]> * Allow passing options in spinner.New This doesn't break existing code as it uses variadic arguments, so any existing code as the following should continue to work: s := spinner.New() s.spinner = spinner.Dot This change allows for instead of those two lines, having a call: s := spinner.New(spinner.WithSpinner(spinner.Dot)) Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.WithX option for each spinner.Spinner Signed-off-by: Leandro López (inkel) <[email protected]> * Refactor spinner tests Signed-off-by: Leandro López (inkel) <[email protected]> * Add spinner.WithStyle option function Signed-off-by: Leandro López (inkel) <[email protected]> * refactor: remove With... Spinner aliases Co-authored-by: Maas Lalani <[email protected]>
This PR introduces a
spinner.Option
type that allows passing configuration options when creating new spinners usingspinner.New
. This doesn't break existing code as it uses variadic arguments, so any existing code as the following should continue to work:This code now can be written as:
In order not to be overly verbose, a
With
function was defined for each of the pre-existing spinners, so one can have for instance:Last but not least it also adds a
WithStyle(lipgloss.Style)
option function.This is mostly syntactic sugar, but helps when you have a custom model and want to create it:
Without these functions the call above has to be written as: