You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scenario: You have a command that outputs raw data (like json or csv) to the console, and it uses laravel/prompts. You want to save the output to a file, so you run php artisan some:command > path/to/file.json.
Unfortunately the prompt is using stdout, so it gets sent to the file and you don't see anything in the console.
I figured out a workaround that makes the prompt use stderr:
$output = $this->getOutput()->getOutput();
if ($outputinstanceof ConsoleOutputInterface) {
Prompt::setOutput($output->getErrorOutput());
}
It works great, but it would be nice if there was an easier and more intuitive way of doing it. Maybe an optional argument that allows you to pass an OutputInterface, or a static Prompt::stderr() method. And maybe consider using stderr by default in the next major release, unless there are any drawbacks that I'm not aware of.
The text was updated successfully, but these errors were encountered:
Scenario: You have a command that outputs raw data (like json or csv) to the console, and it uses laravel/prompts. You want to save the output to a file, so you run
php artisan some:command > path/to/file.json
.Unfortunately the prompt is using stdout, so it gets sent to the file and you don't see anything in the console.
I figured out a workaround that makes the prompt use stderr:
It works great, but it would be nice if there was an easier and more intuitive way of doing it. Maybe an optional argument that allows you to pass an OutputInterface, or a static
Prompt::stderr()
method. And maybe consider using stderr by default in the next major release, unless there are any drawbacks that I'm not aware of.The text was updated successfully, but these errors were encountered: