-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use any color #69
Comments
Hey @KimNorgaard This sounds like a great idea. A PR would be awesome if you have the time. Thanks! |
So, I might have prematurely proclaimed this an easy fix. Well.. it sort of is, but it will break backwards compatibility. My solution was to completely replace the current abstraction in the On the positive side, with this change, it would be possible to use One way to keep backwards compatibility would be to use generics in the I would probably also add option methods (like Let me know what you think. |
Just to give you an idea, I did a quick change here: https://github.com/KimNorgaard/ysmrr/tree/custom-colors It doesn't support using One currently has the disadvantage that you have to create the manager with type assertion (e.g. |
Hey, I took a look at your branch. It looks nice but it's a fairly big change to the public API.. I'm wondering if there is a simpler direction. Maybe duplicating the colors (or adding a v2) package and providing a whole new set of methods to manage colors. It's not as elegant but allows both to co-exist and the for the first to be safely deprecated. With regards to exposing color.Color, my original idea was to have an abstraction in place so that the user is not aware of the underlying dependency and also to allow for potential future changes (for example, swapping out the package). Does that make sense? |
I agree it is a big change and I also don't think it's the best solution. My preferred solution would be to go the v2 route like you wrote because it just seems like too much effort to try to maintain backwards compatibility (and not even be completely able to, anyway). The abstraction seems sensible as far as not leaking dependencies goes but since it's already tightly coupled to that specific color library, I'm not sure it's necessary. Duplicating all of the colors (and other attributes) would in essence mean duplicating related functionality from the fatih library. I'm not sure I see the gained advantage over just allowing the user to use all of the functionality already present. Personally I would love to just be able to: col := color.New(color.FgGreen, color.Bold)
sm := ysmrr.NewSpinnerManager(ysmrr.WithSpinnerColor(col)) Of course this makes it harder to replace Ultimately it's up to you. I'm happy to got both routes. |
Yeah you have a point regarding duplication. To be honest, the faith package is really good and I have no plans to move away from it soon. So maybe we go down the v2 route where:
Then I think as a follow up, I'd be really interested in looking in to individual spinner overrides. What do you think? |
I'd like the option to be able to use any color I want.
Currently the number of colors is limited to a few options, but since it's already using
fatih/color
behind the scenes it should be fairly easy to refactor the code to enable any colorfatih/color
supports or evencolor.RGB()
.I could hash out a PR if you like the idea.
The text was updated successfully, but these errors were encountered: