Optional plain JSON result
hingehe opened this issue · 3 comments
Summary
I've had a hard time to read the output of jwt in my programming tool in spite of the -j option, because in error-case it doesn't return plain json as expected:
�[0m�[1m�[31mThe JWT provided is invalid because Error(Base64(InvalidByte(85, 61)))
{
"header": {
"typ": "JWT",
"alg": "ES256",
[...]
Especially the weird color-information in the error should be deactivatable by a new option (like --plaintext oslt).
Steps to reproduce
Run jwt -j with an expired token for instance
Expected behavior
Return plain JSON wrapping the current one with something like that without color codes:
{
"result: {
"error": "The JWT provided is invalid because Error(Base64(InvalidByte(85, 61)))"
}
"header": {
"typ": "JWT",
"alg": "ES256",
[...]
Sorry for the late reply @hingehe. Can you tell me a bit more about your programming tool? Is it a TTY or not? Anything else I could look for to strip color and formatting?
I am working with a EAI Tool called "inubit".
I execute your script with a "CLI Execution module" on a linux system (so I think it is a TTY-Tool in your sense). The result (refer my previous post) has weird characters. My tool tries to wrap everything into an XML structure. This fails, whit these color coding characters, because of charset foo.
I fixed the problem with replace (regular expressions) in my CLI script, so I remove those characters. But this is of course not the best option. An optional parameter to suppress any color codings would be perfect for my needs.
Hi again @hingehe, sorry for the delayed response. The output crate I use is bunt
, which uses termcolor
itself. bunt
will automatically print to stdout with the auto
color mode. In that mode, output on windows won't be colored, but also if the environment variable NO_COLOR
is defined, then it won't output colors.
That being said, can you try defining NO_COLOR
in your environment and see if that works for you? If it does, I'll find a place to document it 😄