protected function interact(InputInterface $input, OutputInterface $output)
    {
        $console = $this->getHelper('question');

        $output->writeln(
            [
                '',
                'This command will create a <info>user</info> for <comment>Shuwee admin</comment>',
                '',
            ]
        );

        // Username
        $username = null;
        try {
            $username = $input->getArgument('username') ? $this->usernameValidator(
                $input->getArgument('username')
            ) : null;
        } catch (\Exception $error) {
            $output->writeln($console->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $username) {
            $question = new Question('<info>Username</info>: ');
            $question->setValidator([$this, 'usernameValidator']);
            $question->setMaxAttempts(self::MAX_ATTEMPTS);
            $username = $console->ask($input, $output, $question);
            $input->setArgument('username', $username);
        } else {
            $output->writeln('<info>Username</info>: '.$username);
        }

        // Password
        $password = null;
        try {
            $password = $input->getArgument('password') ? $this->passwordValidator(
                $input->getArgument('password')
            ) : null;
        } catch (\Exception $error) {
            $output->writeln($console->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $password) {
            $question = new Question('<info>Password</info> (your type will be hidden): ');
            $question->setValidator([$this, 'passwordValidator']);
            $question->setHidden(true);
            $question->setMaxAttempts(self::MAX_ATTEMPTS);
            $password = $console->ask($input, $output, $question);
            $input->setArgument('password', $password);
        } else {
            $output->writeln('<info>Password</info>: '.str_repeat('*', strlen($password)));
        }

        $output->writeln('');
    }
protected function interact(InputInterface $input, OutputInterface $output)
    {
        $console = $this->getHelper('question');

        $output->writeln(
            [
                '',
                'This command will create a <info>user</info> for <comment>Shuwee admin</comment>',
                '',
            ]
        );

        // Username
        $username = null;
        try {
            $username = $input->getArgument('username') ? $this->usernameValidator(
                $input->getArgument('username')
            ) : null;
        } catch (\Exception $error) {
            $output->writeln($console->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $username) {
            $question = new Question('<info>Username</info>: ');
            $question->setValidator([$this, 'usernameValidator']);
            $question->setMaxAttempts(self::MAX_ATTEMPTS);
            $username = $console->ask($input, $output, $question);
            $input->setArgument('username', $username);
        } else {
            $output->writeln('<info>Username</info>: '.$username);
        }

        // Password
        $password = null;
        try {
            $password = $input->getArgument('password') ? $this->passwordValidator(
                $input->getArgument('password')
            ) : null;
        } catch (\Exception $error) {
            $output->writeln($console->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
        }

        if (null === $password) {
            $question = new Question('<info>Password</info> (your type will be hidden): ');
            $question->setValidator([$this, 'passwordValidator']);
            $question->setHidden(true);
            $question->setMaxAttempts(self::MAX_ATTEMPTS);
            $password = $console->ask($input, $output, $question);
            $input->setArgument('password', $password);
        } else {
            $output->writeln('<info>Password</info>: '.str_repeat('*', strlen($password)));
        }

        $output->writeln('');
    }
protected function interact ( InputInterface $ input , OutputInterface $ output ) { $ console = $ this -> getHelper ( 'question' ) ; $ output -> writeln ( [ '' , 'This command will create a <info>user</info> for <comment>Shuwee admin</comment>' , '' , ] ) ; // Username $ username = null ; try { $ username = $ input -> getArgument ( 'username' ) ? $ this -> usernameValidator ( $ input -> getArgument ( 'username' ) ) : null ; } catch ( \ Exception $ error ) { $ output -> writeln ( $ console -> getHelperSet ( ) -> get ( 'formatter' ) -> formatBlock ( $ error -> getMessage ( ) , 'error' ) ) ; } if ( null === $ username ) { $ question = new Question ( '<info>Username</info>: ' ) ; $ question -> setValidator ( [ $ this , 'usernameValidator' ] ) ; $ question -> setMaxAttempts ( self :: MAX_ATTEMPTS ) ; $ username = $ console -> ask ( $ input , $ output , $ question ) ; $ input -> setArgument ( 'username' , $ username ) ; } else { $ output -> writeln ( '<info>Username</info>: ' . $ username ) ; } // Password $ password = null ; try { $ password = $ input -> getArgument ( 'password' ) ? $ this -> passwordValidator ( $ input -> getArgument ( 'password' ) ) : null ; } catch ( \ Exception $ error ) { $ output -> writeln ( $ console -> getHelperSet ( ) -> get ( 'formatter' ) -> formatBlock ( $ error -> getMessage ( ) , 'error' ) ) ; } if ( null === $ password ) { $ question = new Question ( '<info>Password</info> (your type will be hidden): ' ) ; $ question -> setValidator ( [ $ this , 'passwordValidator' ] ) ; $ question -> setHidden ( true ) ; $ question -> setMaxAttempts ( self :: MAX_ATTEMPTS ) ; $ password = $ console -> ask ( $ input , $ output , $ question ) ; $ input -> setArgument ( 'password' , $ password ) ; } else { $ output -> writeln ( '<info>Password</info>: ' . str_repeat ( '*' , strlen ( $ password ) ) ) ; } $ output -> writeln ( '' ) ; }
Validates input and ask for missing arguments if any
Validates input and ask for missing arguments if any