addArgument('username', InputArgument::REQUIRED, 'The username to generate a token for'); } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $username = $input->getArgument('username'); $user = $this->userRepository->findOneBy(['username' => $username]); if (null === $user) { $io->error(sprintf('User "%s" not found.', $username)); return Command::FAILURE; } $token = bin2hex(random_bytes(32)); $user->setApiToken($token); $this->entityManager->flush(); $io->success(sprintf('API token generated for user "%s":', $username)); $io->writeln($token); return Command::SUCCESS; } }