You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would be nice if kubecolor adds colors to some popular kubectl plugins.
As we can't really assume too much here on a plugin name meaning a specific plugin from a specific author, then this must be configurable to be able to opt-out.
Would be nice with being able to configure printer/parser rules, such as:
# Commands to match printer logic on.# Matching rules:# - First one to match will be used.# - By default args must match exactly.# - If using "hello" then it will match 1 required arg of value "hello"# - If using "[hello]" then it will match 1 optional arg of value "hello"# - If using "<*>" then it will match 1 required arg of any value# - If using "[*]" then it will match 1 optional arg of any value# - If using "/.*/" then it will match 1 optional arg that matches regex# - If using "..." then it will match any number of args of any values.# - Flags are by default ignored.# - Specifying a flag makes it required.commands:
# match if 1st arg is "krew", has flag "--help", and may have any other number of args
- match: ['krew --help ...']printer: help# match if 1st arg is "krew", and has no other args
- match: ['krew']printer: help# match if 1st arg is "krew", 2nd arg has any value, and has no other args
- match: ['krew info <*>']printer: table# match if 1st arg is "krew", 2nd arg is "search", and 3rd is optional and can have any value
- match: ['krew search [*]']printer: table# match if 1st arg is "krew", 2nd is "list", and has no other args
- match: ['krew list']printer: tableflagsWithValue:
- --v # says that the --v flag can have a value, so treat "krew list --v debug" as "krew list --v=debug"# https://github.com/tohjustin/kube-lineage# Matches if --help or -h is used, and any number of arguments
- match: ['lineage --help ...', 'lineage -h ...']printer: help# Matches any other lineage commands, like "lineage clusterrole cluster-admin"
- match: ['lineage ...']printer: table
The above config format is me brainstorming a bit. But something as simple as that would still be super useful and quite powerful.
Maybe to speed things up, and to make the config easier to read, it could do nested matches:
commands:
- match: ['krew ...']# defining flagsWithValue here means that it is also applied to child commandsflagsWithValue:
- --v # says that the --v flag can have a value, so treat "krew list --v debug" as "krew list --v=debug"commands:
# match if 1st arg is "krew", has flag "--help", and may have any other number of args
- match: ['krew --help ...']printer: help# match if 1st arg is "krew", and has no other args
- match: ['krew']printer: help# match if 1st arg is "krew", 2nd arg has any value, and has no other args
- match: ['krew info <*>']printer: table# match if 1st arg is "krew", 2nd arg is "search", and 3rd is optional and can have any value
- match: ['krew search [*]']printer: table# match if 1st arg is "krew", 2nd is "list", and has no other args
- match: ['krew list']printer: table# https://github.com/tohjustin/kube-lineage
- match: ['lineage']commands:
# Matches if --help or -h is used, and any number of arguments
- match: ['lineage --help ...', 'lineage -h ...']printer: help# Matches any other lineage commands, like "lineage clusterrole cluster-admin"
- match: ['lineage ...']printer: table
The logic for kubecolor would be to just traverse the list on demand, and it can basically do a tree walk. On the first occurrence of it matching (and that match defines the printer) then use the given printer.
As an implementation detail, this could also be used for the regular kubectl commands too, but let kubecolor add those configs to the end of the commands list so they're only used as fallback.
That way we could probably clean up a bunch of the printer/*.go code as a lot of it is just repetition.
Current Behavior
kubecolor strictly disables coloring if its a kubectl plugin, and has no configurable printer rules.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Operating System: linux
kubectl version: v1.29.4
kubecolor version: v0.3.1
The text was updated successfully, but these errors were encountered:
Expected Behavior
Would be nice if kubecolor adds colors to some popular kubectl plugins.
As we can't really assume too much here on a plugin name meaning a specific plugin from a specific author, then this must be configurable to be able to opt-out.
Would be nice with being able to configure printer/parser rules, such as:
The above config format is me brainstorming a bit. But something as simple as that would still be super useful and quite powerful.
Maybe to speed things up, and to make the config easier to read, it could do nested matches:
The logic for kubecolor would be to just traverse the list on demand, and it can basically do a tree walk. On the first occurrence of it matching (and that match defines the
printer
) then use the given printer.As an implementation detail, this could also be used for the regular kubectl commands too, but let kubecolor add those configs to the end of the
commands
list so they're only used as fallback.That way we could probably clean up a bunch of the
printer/*.go
code as a lot of it is just repetition.Current Behavior
kubecolor strictly disables coloring if its a kubectl plugin, and has no configurable printer rules.
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
The text was updated successfully, but these errors were encountered: