Преглед изворни кода

Merge remote-tracking branch 'miklosm/iss1347'

Jordi Boggiano пре 12 година
родитељ
комит
3fd887ffce
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      src/Composer/Command/InitCommand.php

+ 9 - 1
src/Composer/Command/InitCommand.php

@@ -64,6 +64,7 @@ class InitCommand extends Command
                 new InputOption('require', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Package to require with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
                 new InputOption('require-dev', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Package to require for development with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or "foo/bar 1.0.0"'),
                 new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
+                new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
             ))
             ->setHelp(<<<EOT
 The <info>init</info> command creates a basic composer.json file
@@ -80,7 +81,7 @@ EOT
     {
         $dialog = $this->getHelperSet()->get('dialog');
 
-        $whitelist = array('name', 'description', 'author', 'homepage', 'require', 'require-dev', 'stability');
+        $whitelist = array('name', 'description', 'author', 'homepage', 'require', 'require-dev', 'stability', 'license');
 
         $options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
 
@@ -254,6 +255,13 @@ EOT
         );
         $input->setOption('stability', $minimumStability);
 
+        $license = $input->getOption('license') ?: false;
+        $license = $dialog->ask(
+            $output,
+            $dialog->getQuestion('License', $license)
+        );
+        $input->setOption('license', $license);
+
         $output->writeln(array(
             '',
             'Define your dependencies.',