setName(self::NAME) ->setDescription('Returns the long URL behind a short code') ->addArgument('shortCode', InputArgument::REQUIRED, 'The short code to parse') ->addOption('domain', 'd', InputOption::VALUE_REQUIRED, 'The domain to which the short URL is attached.'); } protected function interact(InputInterface $input, OutputInterface $output): void { $shortCode = $input->getArgument('shortCode'); if (! empty($shortCode)) { return; } $io = new SymfonyStyle($input, $output); $shortCode = $io->ask('A short code was not provided. Which short code do you want to parse?'); if (! empty($shortCode)) { $input->setArgument('shortCode', $shortCode); } } protected function execute(InputInterface $input, OutputInterface $output): ?int { $io = new SymfonyStyle($input, $output); try { $url = $this->urlResolver->resolveShortUrl(ShortUrlIdentifier::fromCli($input)); $output->writeln(sprintf('Long URL: %s', $url->getLongUrl())); return ExitCodes::EXIT_SUCCESS; } catch (ShortUrlNotFoundException $e) { $io->error($e->getMessage()); return ExitCodes::EXIT_FAILURE; } } }