schedule-bundle icon indicating copy to clipboard operation
schedule-bundle copied to clipboard

Add metadata with more bare results to Result

Open gisostallenberg opened this issue 2 years ago • 3 comments

After tasks are run a Result is created, but some result data is formatted or discarded. For example if a Process fails:

        return Result::failure(
            $task,
            "Exit {$process->getExitCode()}: {$process->getExitCodeText()}",
            $process->getOutput().$process->getErrorOutput()
        );

in ProcessTaskRunner makes it impossible to get the Process and for example get the exit code (without extracting it from the description).

I suggest to add an array with metadata as last argument of Result::__construct and all related static methods which can accept various data regarding the run of the task. The Process for a process task run, the plain output for a callback task run, the plain output and exit code for a command task run, ...

An alternative would be to add an AfterTaskRun event with the above details of the task that ran and dispatch this in each task runners invoke method.

gisostallenberg avatar Jul 22 '22 08:07 gisostallenberg

I agree, would you be willing to create a PR?

kbond avatar Jul 22 '22 12:07 kbond

Would you rather see an additional argument or an event?

gisostallenberg avatar Jul 27 '22 11:07 gisostallenberg

Another argument seems simplest.

kbond avatar Jul 27 '22 11:07 kbond