cb372/sbt-client

[Suggestion] -no-colors and -start-server

vincenzobaz opened this issue · 3 comments

I have the necessity to log the output of sbt-client to a text file but the color codes used for the output are not easily readable when not viewed in a terminal.
When I use sbt I can pass the -no-colors options. Using the same option with sbt-client results in an error:

[error] sbt failed to execute our command. Error code: -33000, message: ''`

It would be useful to have this option.
Another nice option would be something like -start-server to tell sbt-client to start the sbt server right away without waiting as it currently does if sbt is not already running.

Until this option will be implemented by someone, a temporary solution would be to pipe sbt-client's output to this GNU sed rule:

$ sbt-client compile | sed -ur "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g"

It will strip the colors from the output, so the output is usable in vim's quickfix window ;).

cb372 commented

This is an interesting one, because the -no-colors option has to be passed when you start the sbt server. sbt-client only starts the server if it's not already running, so the behaviour would be different depending on whether the server was already running or was started by sbt-client.

I guess sbt-client could reimplement sbt's -no-colors feature by rewriting the responses from sbt, similar to @antekone's sed command.

Thank you @cb372 for answering.
I did not know that the flag had to be set on startup.I do no think that it is a nice I idea to rewrite the output using @antekone 's command in sbt-client. I solved my issue by starting sbt with the flag.

I think that sbt-client should accept a config file or a string or read an environment variable with the flags to pass to sbt upon its startup but it's definitely not a high priority feature.
I do not know any Rust or I'd look into it :(