This message was deleted.
# community-support
s
This message was deleted.
v
🤔
But might be, that I force color in the log4j config
s
Interesting. I'd be curious how "normal" non-log output behaves. I'm referring to clikt / mordant, BTW: https://github.com/ajalt/clikt/issues/428
e
there is no protocol for indicating "this pipe accepts ANSI terminal escapes" (nor any other types of content negotiation)
s
So is my assumption correct that the app's output gets piped when using Gradle's
run
task? If so, why does it need to get piped in the first place?
e
hypothetically Gradle could run child processes in a pty with environment set up so that they think they're attached to a real terminal, then parse and forward everything from there. but that's likely to cause other issues
it can only be piped because everything is run by the Gradle daemon which is not attached to the terminal that the Gradle client is on
s
Oh...
v
Even if the Gradle client would run it directly, (which it could if it is compatible to the daemon args and run with
--no-daemon
), it would probably be piped, because you still run one process from another.
Many commands like
grep
have an argument with which you can tell it to "always" color, "never" color, or "auto-detect" color.
s
Well, naively, if I could just use
ProcessBuilder
(without redirection configured) to spawn another process, that should work, or?
v
If clickt does not support that, you should open a feature request and if it does, you should configure it 🙂
Well, naively, if I could just use
ProcessBuilder
(without redirection configured) to spawn another process, that should work, or
Most probably not
s
Forcing color is not really a solution IMO, just a work-around.
v
Yes, it is a work-around you need when piping the command like when running it through
grep
or piping it to
less
or running it through Gradle Daemon
s
Unless there's a reliable way to tell whether an app is being run by Gradle / the daemon... and only then force color.
e
you can consider it a workaround but the whole idea of terminal detection is a bigger mess
âž• 1
v
Also, there is no "standard" interactive console recognition. If you for example run older Gradle versions in Git Bash, you get pretty ugly output as the recognition there did not work properly.
e
even if you're running in a daemon, you have no way to tell if the client on the other end supports color
v
Unless there's a reliable way to tell whether an app is being run by Gradle / the daemon... and only then force color.
That's exactly what I said
Configure the
run
task with an argument like
--color=always
for
grep
, then you have exaclty that
If clickt does not support something like that, it should definitely be added, because your application could also be piped to
grep
or
less
or whatever and the end-user might still preserve color even if piped.
s
> Unless there's a reliable way to tell whether an app is being run by Gradle / the daemon... and only then force color.
That's exactly what I said
Well, what I thought you were saying is that my clikt app should support
--force-color
and I should specify that manually when I know I'm running via Gradle.
v
Yes, your clickt app should support forcing color and suppressing color
But to force when run through Gradle is configured via build script of course
e
if you know you only ever run Gradle in environments with color support, then go ahead and configure it to tell the commands to force color. this has to be done out of band because UNIX pipes are dumb.
s
Ah. That would not scale for all clikt users though. If feasile, there should be clikt-built-in logic to determine whether it's being run via Gradle, and then automatically force color.
e
that would still be the wrong thing to do
if Gradle is being run in GitHub Actions for example, there is no color support in the output
you have no way to know and the existing terminal detection that everybody does is a very limited workaround for the inadequacies of UNIX
v
That would not scale for all clikt users though.
Why not? I as user of a tool that uses clickt would hate it as hell if I can not suppress color or enforce color how I need it.
No recognition can ever be as good as my decision
And what @ephemient said
e
I don't see why there should be anything special about clikt - the only solution is what @Vampire mentioned that every other cli tool does, which is to have flags to disable detection and force color on or off
v
Just that it is run by Gradle is not enough to know it should force color eventually, except you only ever call that task manually, but that's why the task configuration should configure it as I said and not clickt magically recognizing it is run through Gradle which it cannot anyway.
s
Ok, understood.