You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.2 KiB

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Command\TaskProcessing;
  8. use OC\Core\Command\Base;
  9. use OCP\TaskProcessing\IManager;
  10. use Symfony\Component\Console\Input\InputArgument;
  11. use Symfony\Component\Console\Input\InputInterface;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class GetCommand extends Base {
  14. public function __construct(
  15. protected IManager $taskProcessingManager,
  16. ) {
  17. parent::__construct();
  18. }
  19. protected function configure() {
  20. $this
  21. ->setName('taskprocessing:task:get')
  22. ->setDescription('Display all information for a specific task')
  23. ->addArgument(
  24. 'task-id',
  25. InputArgument::REQUIRED,
  26. 'ID of the task to display'
  27. );
  28. parent::configure();
  29. }
  30. protected function execute(InputInterface $input, OutputInterface $output): int {
  31. $taskId = (int)$input->getArgument('task-id');
  32. $task = $this->taskProcessingManager->getTask($taskId);
  33. $jsonTask = $task->jsonSerialize();
  34. $jsonTask['error_message'] = $task->getErrorMessage();
  35. $this->writeArrayInOutputFormat($input, $output, $jsonTask);
  36. return 0;
  37. }
  38. }