Closed Namoshek closed 2 years ago
Sounds promising, sure. Please submit a pull request on it.
Note: Try not to make breaking changes.
The second suggestion should be possible without a breaking change, while the former isn't. Reason is this line $result = $task() === false ? false : true;
. We implicitely assume everything that isn't exactly false
to be true
. Even 0
is considered true
.
Allowing tasks to return arbitrary content such as return 'nothing to do';
will not break the $result
, but it would change the command output from <info>✔</info>
to <info>nothing to do</info>
. So I guess it's not really BC.
Currently, there is only two types of results a task can create in the console:
I came accross situations, where it would be beneficial to be able to display a different result, for example:
Quick thinking brought me to the result that all of these situations are success scenarios and no failures. Which means it should be possible to adapt the current code in a way that custom errors are displayed. So my question is: would a change like this be desired? Of course I would prepare a PR for it.
Alternative suggestion: allow tasks to add additional output, which is displayed in a way that makes it obvious to which task it belongs
I'm not yet sure what would be the most practical way of implementing this. Also I'm not sure it would work well with the
if ($this->output->isDecorated()) { /* rewrite the line */ }
part. But I'm sure there is a way. So what are your opinions on this @nunomaduro?