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
Is your feature request related to a problem? Please describe.
Currently when running for example mimirtool rules print | less or mimirtool rules print > rules.yaml, it outputs ansi color codes, which show up in the output and make the yaml not valid. This happens always, unless you use the --disable-color option. Using the --disable-color works ok if you know about it already and for scripts, but anyone using the tool interactively has to remember to use it when piping to a pager or a parser like yq.
Describe the solution you'd like
Detect when the output is redirected to anything other than a terminal, and don't print color codes in those cases.
Describe alternatives you've considered
Additional context
Detecting if printing to a tty is a common pattern with other CLI tools, for example jq or tree. Having the default option being auto, and than allowing forcing color or disabling it is reasonable solution IMO.
The text was updated successfully, but these errors were encountered:
Would this require adding another flag (--force-color) to override the setting when the output is not a terminal but we still want colors for some reason? Which flag would take precedence if they are both specified?
Is that the desirable outcome or just removing colors would be enough?
Would this require adding another flag (--force-color) to override the setting when the output is not a terminal but we still want colors for some reason? Which flag would take precedence if they are both specified? Is that the desirable outcome or just removing colors would be enough?
I think adding a flag to output color anyway is useful, for example to allow piping to less -R which will show the colors.
I'm not sure about the naming though. Precedence should probably take the last specified option?
Is your feature request related to a problem? Please describe.
Currently when running for example
mimirtool rules print | less
ormimirtool rules print > rules.yaml
, it outputs ansi color codes, which show up in the output and make the yaml not valid. This happens always, unless you use the--disable-color
option. Using the --disable-color works ok if you know about it already and for scripts, but anyone using the tool interactively has to remember to use it when piping to a pager or a parser likeyq
.Describe the solution you'd like
Detect when the output is redirected to anything other than a terminal, and don't print color codes in those cases.
Describe alternatives you've considered
Additional context
Detecting if printing to a tty is a common pattern with other CLI tools, for example
jq
ortree
. Having the default option being auto, and than allowing forcing color or disabling it is reasonable solution IMO.The text was updated successfully, but these errors were encountered: