setName('sharing:create-share') ->setDescription('Create a new share.') ->addArgument('owner', InputArgument::REQUIRED, 'User ID of the owner'); } #[\Override] public function execute(InputInterface $input, OutputInterface $output): int { /** @var string $ownerUid */ $ownerUid = $input->getArgument('owner'); $owner = Server::get(IUserManager::class)->get($ownerUid); if ($owner === null) { throw new ShareInvalidException('The owner does not exist: ' . $ownerUid, Server::get(IFactory::class)->get('sharing')->t('The owner does not exist: %s', [$ownerUid])); } return $this->wrapExecution($output, fn (): string => $this->manager->createShare(new ShareAccessContext($owner))); } }