Open Sweetchuck opened 2 years ago
Robo makes an effort to hide and re-show the progress bar when it writes other output; however, there is an existing bug when exec
-ing external programs.
The progress bar should auto-disable when stdout is redirected. If it does not, you can turn it off via an option, --no-progress
, I presume.
exec
-ing external programs"--no-progress
option among the global options. (--help --quiet --version --ansi --no-interaction --simulate --progress-delay --define --verbose)My main problem is that sometimes a log entry or an StdOutput line or an StdError line are in the same line with the progress bar.
Like this:
0/4 [>---------------------------] 0% < 1 sec/< 1 sec [info] c
or like this:
3/4 [=====================>------] 75% 6 secs/8 secsstdOutput line 1
A little bit messy and very difficult to read, and hard to follow what is going on.
In the example above there is no "exec-ing external programs"
There may be other bugs in addition to the exec bug. Compare against ./robo try:progress
, which works correctly. Log output works. I don't know if any other sort of output does.
I could not find the --no-progress option among the global options
Sorry, my mistake. --progress-delay=-1
will do the trick.
Also, in my experience, ./robo try:progress --progress-delay=0 | cat
is disabling the progress bar, as it should when stdout is redirected. I don't know why you are still getting progress output when using redirection.
The simplified version of my command:
public function myCmd(): CommandResult
{
$cb = $this->collectionBuilder();
$cb->addTask($this->taskFoo());
$result = $cb->run();
return CommandResult::data($result['my_list']);
}
When I do nothing extra and I run this command: robo my:cmd > output.txt
And I open the output.txt file with a hexeditor
then the first two characters are:
0D 0A
. chr(13)chr(10)
\r\n
The "\r" is a little bit surprising, because the running OS is openSUSE Tumbleweed (Linux). I assume it is related to the progressBar re-drawing.
The stdOutput is the same with --progress-delay=0
and 2>/dev/null
The progressBar is always there even with --progress-delay=0
or -1
or 9999
The progressBar is always there even with --progress-delay=X | cat
.
When I initialise the collection builder like this:
$nullOutput = new NullOutput();
$nullLogger = new NullLogger();
$io = new ConsoleIO(Robo::input(), $nullOutput);
$progressBar = new ProgressBar($nullOutput, 0, 99999);
$progressIndicator = new ProgressIndicator($progressBar, $nullOutput);
$cb = $this->collectionBuilder($io);
$cb->setLogger($nullLogger);
$cb->setProgressIndicator($progressIndicator);
Then the stdOutput is the expected.
I think the progressBar manager for some operation uses the stdOutput instead of the stdError.
When a a symfony progressBar receives the $output it checks that if it is a ConsoleOutputInterface or not, if it is, then uses the srdError part. https://github.com/symfony/console/blob/5.4/Helper/ProgressBar.php#L71
\Robo\Common\ProgressIndicator does not do such a checking, just uses it directly. https://github.com/consolidation/robo/blob/1daaeae3964fb5bba5b2dbc8a286356bbebd124f/src/Common/ProgressIndicator.php#L59
Steps to reproduce
Command:
./vendor/bin/robo --load-from='RoboFileDummy.php' -vv dummy:progressbar
Actual output:
Expected:
Command:
./vendor/bin/robo --load-from='RoboFileDummy.php' -vv dummy:progressbar 2>/dev/null
Actual output:
Expected output
Same as above but without the
$this->output()->writeln('stdOutput line 1');
lines.Command:
./vendor/bin/robo --load-from='RoboFileDummy.php' -vv dummy:progressbar 2>/dev/null
Actual output: The output starts with an empty line.
Expected output
The leading empty line not just a blemish, because it can cause problem in certain use cases.
robo dummy:progressbar | xargs ...
Other progressbar related issues:
674
System Configuration
consolidation/robo 3.x