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
My use case: I am running various conan commands in a wrapper script. The wrapper is using its own buffering when running subprocesses, so when I run the script in the terminal, conan doesn't know that it actually runs in terminal, and disables colors in logs. I set CLICOLOR_FORCE env variable when I want to see colored logs, which works nicely for me.
Sadly, when I want to capture stdout of a command and do something with it, CLICOLOR_FORCE adds unwanted escape sequences and breaks my script:
$ conan list 'zlib/*' --format=json | cat -A
{$
"Local Cache": {$
"zlib/1.2.13": {}$
}$
}$
$ CLICOLOR_FORCE=1 conan list 'zlib/*' --format=json | cat -A
{$
"Local Cache": {$
"zlib/1.2.13": {}$
}$
}^[[0m$
Same can be observed if I run simple conan config home. This is kinda expected since I add a variable to force colors, but JSON output format is meant to be processed automatically, so I think it shouldn't be touched with color decorations at all.
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
It could make sense to add color decorators in cli_out_write only when either fg or bg is not None, this would be enough for my use case. I can prepare a PR myself if it is OK with you!
I agree, when printing to stdout any json it shouldn't use any escape sequences at all, irrespective of all colors enabled or forced. It makes sense to fix cli_out_write() method so this doesn't happen. It would also make sense to use print() or sys.stdout.write() for many outputs like json files that don't use colors, but probably fix cli_out_write() will be simpler. Thanks for offering to submit a PR!
What is your suggestion?
Hi!
My use case: I am running various conan commands in a wrapper script. The wrapper is using its own buffering when running subprocesses, so when I run the script in the terminal, conan doesn't know that it actually runs in terminal, and disables colors in logs. I set CLICOLOR_FORCE env variable when I want to see colored logs, which works nicely for me.
Sadly, when I want to capture stdout of a command and do something with it, CLICOLOR_FORCE adds unwanted escape sequences and breaks my script:
Same can be observed if I run simple
conan config home
. This is kinda expected since I add a variable to force colors, but JSON output format is meant to be processed automatically, so I think it shouldn't be touched with color decorations at all.Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: