maven-mvnd icon indicating copy to clipboard operation
maven-mvnd copied to clipboard

Interactive progress should go to stderr, not stdout

Open electrum opened this issue 4 years ago • 3 comments

I need to get a list of dependencies for my project:

mvnd dependency:tree > out

This ran super fast, because mvnd is awesome, but it didn't show me the progress while running, and worse, the progress with all of the terminal escape codes was included in the output file from stdout. Also, the log output in the file was colored.

The behavior I expect is for mvnd to use stderr for progress, but only if stderr is a TTY, and that the log output to stdout is only colored if stdout is a TTY. This would match the behavior of the normal mvn command, except it would be fast and show the nice interactive progress:

mvn dependency:tree > out

electrum avatar Feb 13 '21 01:02 electrum

While I tend to agree, there is currently a limitation in JLine which does not support setting up a terminal with stdin/stderr instead of stdin/stdout, so this will require a new JLine feature / release.

For the ansi sequences, they could be stripped out. Note that the -l command line option should also be handled accordingly.

gnodet avatar Feb 15 '21 12:02 gnodet

Standard Maven's -B could help to get rid of the ansi sequences.

ppalaga avatar Feb 15 '21 12:02 ppalaga

As a workaround, the desired behavior (progress + file output) can be achieved using the standard maven option

mvnd dependency:tree -l out

though the output in the out file still contains ansi sequences, but I'll fix this issue.

gnodet avatar Feb 15 '21 13:02 gnodet