setName('files_external:delete') ->setDescription('Delete an external mount') ->addArgument( 'mount_id', InputArgument::REQUIRED, 'The id of the mount to edit' )->addOption( 'yes', 'y', InputOption::VALUE_NONE, 'Skip confirmation' ); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output): int { $mountId = $input->getArgument('mount_id'); try { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"'); return Http::STATUS_NOT_FOUND; } $noConfirm = $input->getOption('yes'); if (!$noConfirm) { $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); $listInput = new ArrayInput([], $listCommand->getDefinition()); $listInput->setOption('output', $input->getOption('output')); $listCommand->listMounts(null, [$mount], $listInput, $output); /** @var QuestionHelper $questionHelper */ $questionHelper = $this->getHelper('question'); $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); if (!$questionHelper->ask($input, $output, $question)) { return self::FAILURE; } } $this->globalService->removeStorage($mountId); return self::SUCCESS; } }