diff --git a/src/Command/Activity/ActivityGetCommand.php b/src/Command/Activity/ActivityGetCommand.php index b280a6ab4..e3f8e3653 100644 --- a/src/Command/Activity/ActivityGetCommand.php +++ b/src/Command/Activity/ActivityGetCommand.php @@ -131,7 +131,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $rows = []; foreach ($properties as $property => $value) { $header[] = $property; - $rows[] = $this->propertyFormatter->format($value, $property); + if ($property === 'result') { + $rows[] = ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()); + } else { + $rows[] = $this->propertyFormatter->format($value, $property); + } } $this->table->renderSimple($rows, $header); diff --git a/src/Command/Activity/ActivityListCommand.php b/src/Command/Activity/ActivityListCommand.php index 501ee337e..dfaca47b1 100644 --- a/src/Command/Activity/ActivityListCommand.php +++ b/src/Command/Activity/ActivityListCommand.php @@ -135,7 +135,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]), 'progress' => $activity->getCompletionPercent() . '%', 'state' => ActivityMonitor::formatState($activity->state), - 'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()), + 'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()), 'environments' => implode(', ', $activity->environments), ]; $timings = $activity->getProperty('timings', false, false) ?: []; diff --git a/src/Command/Environment/EnvironmentDeployCommand.php b/src/Command/Environment/EnvironmentDeployCommand.php index 857f61af6..7c7ba0b81 100644 --- a/src/Command/Environment/EnvironmentDeployCommand.php +++ b/src/Command/Environment/EnvironmentDeployCommand.php @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'created' => $this->propertyFormatter->format($activity['created_at'], 'created_at'), 'description' => ActivityMonitor::getFormattedDescription($activity, !$this->table->formatIsMachineReadable()), 'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]), - 'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()), + 'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()), ]; $rows[] = $row; } diff --git a/src/Command/Integration/Activity/IntegrationActivityListCommand.php b/src/Command/Integration/Activity/IntegrationActivityListCommand.php index 8fc25ed8f..cffe9dc3e 100644 --- a/src/Command/Integration/Activity/IntegrationActivityListCommand.php +++ b/src/Command/Integration/Activity/IntegrationActivityListCommand.php @@ -109,7 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'type' => new AdaptiveTableCell($activity->type, ['wrap' => false]), 'progress' => $activity->getCompletionPercent() . '%', 'state' => ActivityMonitor::formatState($activity->state), - 'result' => ActivityMonitor::formatResult($activity->result, !$this->table->formatIsMachineReadable()), + 'result' => ActivityMonitor::formatResult($activity, !$this->table->formatIsMachineReadable()), ]; $timings = $activity->getProperty('timings', false, false) ?: []; foreach ($timingTypes as $timingType) { diff --git a/src/Service/ActivityMonitor.php b/src/Service/ActivityMonitor.php index cb3a30c1e..faacdf534 100644 --- a/src/Service/ActivityMonitor.php +++ b/src/Service/ActivityMonitor.php @@ -586,10 +586,19 @@ public static function formatState(string $state): string /** * Formats an activity result. */ - public static function formatResult(string $result, bool $decorate = true): string + public static function formatResult(Activity $activity, bool $decorate = true): string { + $result = $activity->result; $name = self::RESULT_NAMES[$result] ?? $result; + foreach ($activity->commands ?? [] as $command) { + if ($command['exit_code'] > 0) { + $name = Activity::RESULT_FAILURE; + $result = Activity::RESULT_FAILURE; + break; + } + } + return $decorate && $result === Activity::RESULT_FAILURE ? '' . $name . '' : $name;