src/Console/Command/ConfigureCommand.php
protected function buildConfiguration(InputInterface $input, OutputInterface $output): array
    {
        /** @var QuestionHelper $helper */
        $helper = $this->getHelper('question');

        $questionString = $this->createQuestionString(
            'Do you want to create a grumphp.yml file?',
            'Yes'
        );
        $question = new ConfirmationQuestion($questionString, true);
        if (!$helper->ask($input, $output, $question)) {
            return [];
        }

        // Search for git_dir
        $default = $this->guessGitDir();
        $questionString = $this->createQuestionString('In which folder is GIT initialized?', $default);
        $question = new Question($questionString, $default);
        $question->setValidator([$this, 'pathValidator']);
        $gitDir = $helper->ask($input, $output, $question);

        // Search for bin_dir
        $default = $this->guessBinDir();
        $questionString = $this->createQuestionString('Where can we find the executables?', $default);
        $question = new Question($questionString, $default);
        $question->setValidator([$this, 'pathValidator']);
        $binDir = $helper->ask($input, $output, $question);

        // Search tasks
        $tasks = [];
        if ($input->isInteractive()) {
            $question = new ChoiceQuestion(
                'Which tasks do you want to run?',
                $this->getAvailableTasks($this->config)
            );
            $question->setMultiselect(true);
            $tasks = (array) $helper->ask($input, $output, $question);
        }

        // Build configuration
        return [
            'parameters' => [
                'git_dir' => $gitDir,
                'bin_dir' => $binDir,
                'tasks' => array_map(function ($task) {
                    return null;
                }, array_flip($tasks)),
            ],
        ];
    }
protected function buildConfiguration(InputInterface $input, OutputInterface $output): array
    {
        /** @var QuestionHelper $helper */
        $helper = $this->getHelper('question');

        $questionString = $this->createQuestionString(
            'Do you want to create a grumphp.yml file?',
            'Yes'
        );
        $question = new ConfirmationQuestion($questionString, true);
        if (!$helper->ask($input, $output, $question)) {
            return [];
        }

        // Search for git_dir
        $default = $this->guessGitDir();
        $questionString = $this->createQuestionString('In which folder is GIT initialized?', $default);
        $question = new Question($questionString, $default);
        $question->setValidator([$this, 'pathValidator']);
        $gitDir = $helper->ask($input, $output, $question);

        // Search for bin_dir
        $default = $this->guessBinDir();
        $questionString = $this->createQuestionString('Where can we find the executables?', $default);
        $question = new Question($questionString, $default);
        $question->setValidator([$this, 'pathValidator']);
        $binDir = $helper->ask($input, $output, $question);

        // Search tasks
        $tasks = [];
        if ($input->isInteractive()) {
            $question = new ChoiceQuestion(
                'Which tasks do you want to run?',
                $this->getAvailableTasks($this->config)
            );
            $question->setMultiselect(true);
            $tasks = (array) $helper->ask($input, $output, $question);
        }

        // Build configuration
        return [
            'parameters' => [
                'git_dir' => $gitDir,
                'bin_dir' => $binDir,
                'tasks' => array_map(function ($task) {
                    return null;
                }, array_flip($tasks)),
            ],
        ];
    }
protected function buildConfiguration ( InputInterface $ input , OutputInterface $ output ) : array { /** @var QuestionHelper $helper */ $ helper = $ this -> getHelper ( 'question' ) ; $ questionString = $ this -> createQuestionString ( 'Do you want to create a grumphp.yml file?' , 'Yes' ) ; $ question = new ConfirmationQuestion ( $ questionString , true ) ; if ( ! $ helper -> ask ( $ input , $ output , $ question ) ) { return [ ] ; } // Search for git_dir $ default = $ this -> guessGitDir ( ) ; $ questionString = $ this -> createQuestionString ( 'In which folder is GIT initialized?' , $ default ) ; $ question = new Question ( $ questionString , $ default ) ; $ question -> setValidator ( [ $ this , 'pathValidator' ] ) ; $ gitDir = $ helper -> ask ( $ input , $ output , $ question ) ; // Search for bin_dir $ default = $ this -> guessBinDir ( ) ; $ questionString = $ this -> createQuestionString ( 'Where can we find the executables?' , $ default ) ; $ question = new Question ( $ questionString , $ default ) ; $ question -> setValidator ( [ $ this , 'pathValidator' ] ) ; $ binDir = $ helper -> ask ( $ input , $ output , $ question ) ; // Search tasks $ tasks = [ ] ; if ( $ input -> isInteractive ( ) ) { $ question = new ChoiceQuestion ( 'Which tasks do you want to run?' , $ this -> getAvailableTasks ( $ this -> config ) ) ; $ question -> setMultiselect ( true ) ; $ tasks = ( array ) $ helper -> ask ( $ input , $ output , $ question ) ; } // Build configuration return [ 'parameters' => [ 'git_dir' => $ gitDir , 'bin_dir' => $ binDir , 'tasks' => array_map ( function ( $ task ) { return null ; } , array_flip ( $ tasks ) ) , ] , ] ; }
This method will ask the developer for it's input and will result in a configuration array.
This method will ask the developer for it s input and will result in a configuration array .