addArgument('name', InputArgument::OPTIONAL, 'User name'); $this->addArgument('password', InputArgument::OPTIONAL, 'User password'); $this->addArgument('host', InputArgument::OPTIONAL, 'User host'); } protected function execute(InputInterface $input, OutputInterface $output): int { $question = $this->getHelper('question'); $name = $input->getArgument('name'); $password = $input->getArgument('password'); $host = $input->getArgument('host'); if (!$name) { $name = $question->ask($input, $output, new Question('User name: ')); } if (!$password) { $passwordQuestion = new Question('User password: '); $passwordQuestion->setHidden(true); $password = $question->ask($input, $output, $passwordQuestion); } $this->db->createUser($name, $password, $host); $output->writeln(sprintf('User "%s" successfully created', $name)); return Command::SUCCESS; } }