1
0

Export.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Command;
  8. use Symfony\Component\Console\Input\ArrayInput;
  9. use Symfony\Component\Console\Input\InputArgument;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Input\InputOption;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class Export extends ListCommand {
  14. protected function configure(): void {
  15. $this
  16. ->setName('files_external:export')
  17. ->setDescription('Export mount configurations')
  18. ->addArgument(
  19. 'user_id',
  20. InputArgument::OPTIONAL,
  21. 'user id to export the personal mounts for, if no user is provided admin mounts will be exported'
  22. )->addOption(
  23. 'all',
  24. 'a',
  25. InputOption::VALUE_NONE,
  26. 'show both system wide mounts and all personal mounts'
  27. );
  28. }
  29. protected function execute(InputInterface $input, OutputInterface $output): int {
  30. $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
  31. $listInput = new ArrayInput([], $listCommand->getDefinition());
  32. $listInput->setArgument('user_id', $input->getArgument('user_id'));
  33. $listInput->setOption('all', $input->getOption('all'));
  34. $listInput->setOption('output', 'json_pretty');
  35. $listInput->setOption('show-password', true);
  36. $listInput->setOption('full', true);
  37. $listCommand->execute($listInput, $output);
  38. return self::SUCCESS;
  39. }
  40. }