-
Notifications
You must be signed in to change notification settings - Fork 60
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
Custom color selectors support #111
base: master
Are you sure you want to change the base?
Conversation
Custom color selector is a Class with extended logic. For example compare two numbers and select color by percents using.
I'm not sure to understand which problem this (nice code) solves. So far I don't see anything which would not be solved by some regexp magic, like |
Hello.
In this example you are colouring only one number. But goal of this changes was comparing two numbers.
For example:
kubectl get pods -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-5c984bdfb5-j8lvv 1/1 Running 0 6d12h
It is possible than in READY column will be something like this 0/1 (there is no ready instances at all) or 2/20 - only 20% is ready. I believe that it is possible to make this colouring with regex only, but it is not so flexible.
Another goal to create flexible tools for colouring of any cases. PercentSelector is only one case. The main plan was create possibility to make your own colorers inside plugins. Now is possible to make something like this:
class MyCustomSelector(context['Selectors']['percent']):
def color(self, text):
any code here
Inside plugin (e.g. inside def theme(context):) and without touching base code.
… On 12 Aug 2020, at 23:15, nojhan ***@***.***> wrote:
I'm not sure to understand which problem this (nice code) solves. So far I don't see anything which would not be solved by some regexp magic, like echo "80%" | colout "([0-2][0-9])*([3-5][0-9])*([6-9][0-9])*%" green,yellow,red
Can you explain or —even better— add the rationale and some example to the documentation?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#111 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABE76RFWG2ZSQRT4LIXQ2DTSALZ55ANCNFSM4P3FR7NQ>.
|
OK, I understand now. I definitely need a doc update before merging, though. |
Sorry for long pause from my side. Do you mean README.md as documentation or https://nojhan.github.io/colout/ <https://nojhan.github.io/colout/> ? I will update README.md soon. Is in enough or I need update something else?
… On 17 Aug 2020, at 20:11, nojhan ***@***.***> wrote:
OK, I understand now. I definitely need a doc update before merging, though.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#111 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABE76RH3QF47RTSMSYHBNPTSBFQFXANCNFSM4P3FR7NQ>.
|
Yes please, the README at least. Ideally the website, but I would understand that the (old) github pages is cumbersome. |
I've starting create color themes for kubectl commands. The first one is kubectl get pods. But I can't create some logic without custom color selectors (like Scale or Rainbow). For example I need two digits comparer that will choose color by percentage ranges. I've created BaseSelector and PercentSelector as child of BaseSelector. BaseSelector should be a parent for any custom selectors. I've push this selectors into context and now it is possible to create any custom selectors inside colout_.py files. Example of usage for custom selectors is kubectlpods theme.
For example
kubectl get pods |colout.py -t kubectlpods