'h', 'longPrefix' => 'help', 'description' => 'Prints a help statement', ]; } protected function provideOptions(): array { return [ self::OPTION_DELIVERY => [ 'prefix' => 'd', 'longPrefix' => self::OPTION_DELIVERY, 'required' => true, 'description' => 'A delivery ID', ], self::OPTION_RECURSIVE => [ 'prefix' => 'r', 'longPrefix' => self::OPTION_RECURSIVE, 'flag' => true, 'description' => 'Remove all the linked resources such as Tests or Items', ], self::OPTION_EXECUTIONS_ONLY => [ 'prefix' => 'e', 'longPrefix' => self::OPTION_EXECUTIONS_ONLY, 'flag' => true, 'description' => 'Remove only the delivery executions of the specified Delivery', ], ]; } protected function provideDescription(): string { return 'TAO Delivery - Delete Delivery'; } protected function run(): Report { $report = Report::createInfo('Deleting Delivery ...'); /** @var DeliveryDeleteService $deliveryDeleteService */ $deliveryDeleteService = $this->getServiceLocator()->get(DeliveryDeleteService::class); $deliveryId = $this->getOption(self::OPTION_DELIVERY); try { $deliveryDeleteService->execute($this->createDeliveryDeleteRequest()); $report->add($deliveryDeleteService->getReport()); } catch (Exception $exception) { $report->add(Report::createError('Failing deleting delivery: ' . $deliveryId)); $report->add(Report::createError($exception->getMessage())); } return $report; } private function createDeliveryDeleteRequest(): DeliveryDeleteRequest { $deliveryDeleteRequest = new DeliveryDeleteRequest($this->getOption(self::OPTION_DELIVERY)); if ($this->getOption(self::OPTION_EXECUTIONS_ONLY)) { $deliveryDeleteRequest->setDeliveryExecutionsOnly(); } if ($this->getOption(self::OPTION_RECURSIVE)) { $deliveryDeleteRequest->setIsRecursive(); } return $deliveryDeleteRequest; } }