nunomaduro / laravel-console-task

✅ Laravel Console Task is a output method for Laravel Console Commands.
MIT License
254 stars 21 forks source link

Support additional task output #12

Closed Namoshek closed 3 years ago

Namoshek commented 4 years ago

As noted in #10, this PR adds support for additional task output. This is done by passing an instance of the new ConsoleTaskOutput class to the task closure. This class offers some of the output methods the Symfony\Component\Console\Output\OutputInterface also offers. All additional output is prefixed with an indentation string, which is customizable through a setter method.

When tasks are run in a console supporting decorated output, the task line containing the loading... string will be replaced using escape sequences (similar to what we had so far). To achieve this, the cursor location will be saved, then the cursor will be moved the number of additionally written lines up and the line will be erased. After rewriting the line with the final status, the cursor location will be restored. This will also work with #11 together nicely.

A quick demo showcasing the example of the readme: render1568053088097

In theory, this is completely backwards compatible. Nevertheless, I would appreciate if some people try this out before it gets merged.

Namoshek commented 4 years ago

@nunomaduro Any feedback on this and #11?