public function execute(Arguments $args, ConsoleIo $io)
    {
        $questions = $args->getOption('force') ? Hash::extract($this->questions, '{n}[default=Y]') : $this->questions;

        foreach ($questions as $question) {
            is_true_or_fail(['question', 'default', 'command'] === array_keys($question), __d('me_tools', 'Invalid question keys'));
            list($question, $default, $command) = array_values($question);

            //The method must be executed if the `force` mode is set or if the
            //  user answers yes to the question
            $toBeExecuted = true;
            if (!$args->getOption('force')) {
                $ask = $io->askChoice($question, $default === 'Y' ? ['Y', 'n'] : ['y', 'N'], $default);
                $toBeExecuted = in_array($ask, ['Y', 'y']);
            }

            if ($toBeExecuted) {
                $command = is_string($command) ? new $command : $command;
                $command->run($args->getOption('verbose') ? ['--verbose'] : [], $io);
            }
        }

        return null;
    }
public function execute(Arguments $args, ConsoleIo $io)
    {
        $questions = $args->getOption('force') ? Hash::extract($this->questions, '{n}[default=Y]') : $this->questions;

        foreach ($questions as $question) {
            is_true_or_fail(['question', 'default', 'command'] === array_keys($question), __d('me_tools', 'Invalid question keys'));
            list($question, $default, $command) = array_values($question);

            //The method must be executed if the `force` mode is set or if the
            //  user answers yes to the question
            $toBeExecuted = true;
            if (!$args->getOption('force')) {
                $ask = $io->askChoice($question, $default === 'Y' ? ['Y', 'n'] : ['y', 'N'], $default);
                $toBeExecuted = in_array($ask, ['Y', 'y']);
            }

            if ($toBeExecuted) {
                $command = is_string($command) ? new $command : $command;
                $command->run($args->getOption('verbose') ? ['--verbose'] : [], $io);
            }
        }

        return null;
    }
public function execute ( Arguments $ args , ConsoleIo $ io ) { $ questions = $ args -> getOption ( 'force' ) ? Hash :: extract ( $ this -> questions , '{n}[default=Y]' ) : $ this -> questions ; foreach ( $ questions as $ question ) { is_true_or_fail ( [ 'question' , 'default' , 'command' ] === array_keys ( $ question ) , __d ( 'me_tools' , 'Invalid question keys' ) ) ; list ( $ question , $ default , $ command ) = array_values ( $ question ) ; //The method must be executed if the `force` mode is set or if the //  user answers yes to the question $ toBeExecuted = true ; if ( ! $ args -> getOption ( 'force' ) ) { $ ask = $ io -> askChoice ( $ question , $ default === 'Y' ? [ 'Y' , 'n' ] : [ 'y' , 'N' ] , $ default ) ; $ toBeExecuted = in_array ( $ ask , [ 'Y' , 'y' ] ) ; } if ( $ toBeExecuted ) { $ command = is_string ( $ command ) ? new $ command : $ command ; $ command -> run ( $ args -> getOption ( 'verbose' ) ? [ '--verbose' ] : [ ] , $ io ) ; } } return null ; }
Executes all available commands
@param Arguments $args The command arguments
@param ConsoleIo $io The console io
@return null|int The exit code or null for success
@uses $questions
Executes all available commands