Beispiel #1
0
 protected function buildOptions(Package $package, InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelperSet()->get('question');
     $force_opts = $input->getOption('with-configure-options');
     if ($force_opts) {
         if (!file_exists($force_opts) || !is_file($force_opts) || !is_readable($force_opts)) {
             throw new \Exception("File '{$force_opts}' is unusable");
         }
         $force_opts = preg_replace(",\\s+,", ' ', file_get_contents($force_opts));
         return [null, $force_opts];
     }
     $options = $package->getConfigureOptions();
     $optionsValue = [];
     foreach ($options as $name => $opt) {
         /* enable/with-<extname> */
         if ($name == $package->getName() || str_replace('-', '_', $name) == $package->getName()) {
             $optionsValue[$name] = (object) ['type' => $opt->type, 'input' => true];
             continue;
         }
         if ($input->getOption('defaults')) {
             $value = $opt->default;
         } else {
             if ($opt->type == 'enable') {
                 $prompt = new ConfirmationQuestion($opt->prompt . ' (default: ' . ($opt->default ? 'yes' : 'no') . '): ', $opt->default);
             } else {
                 $prompt = new Question($opt->prompt . ' (default: ' . ($opt->default ? $opt->default : '') . '): ', $opt->default);
             }
             $value = $helper->ask($input, $output, $prompt);
         }
         $optionsValue[$name] = (object) ['type' => $opt->type, 'input' => $value];
     }
     return [$optionsValue, null];
 }