Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: implements Symfony\Component\Console\Input\InputInterface
 /**
  * {@inheritdoc}
  */
 protected function configure()
 {
     $this->setEventDispatcher(new EventDispatcher());
     parent::configure();
     $this->setName('dancer')->setDisplayName('SkeletonDancer')->addOption('project-directory', null, Option::OPTIONAL_VALUE, 'The root directory of the project, this is where the ".dancer" directory is located. ' . 'When omitted the directory is automatically searched by the first occurrence of the ".dancer" directory
             in the parent directory structure, and falls back to the current working directory.')->addOption('config-file', null, Option::OPTIONAL_VALUE | Option::NULLABLE, 'Configuration file to load. When omitted the file `.dancer.yml` is automatically searched in the parent directory structure. Pass "null" to disable', '')->addOption('overwrite', null, Option::REQUIRED_VALUE, 'Default operation for existing files: abort, skip, force, ask, backup')->setVersion(self::VERSION)->setDebug('true' === getenv('SKELETON_DANCER_DEBUG'))->addStyle(Style::tag('good')->fgGreen())->addStyle(Style::tag('bad')->fgRed())->addStyle(Style::tag('warn')->fgYellow())->addStyle(Style::tag('hl')->fgGreen());
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, function (PreHandleEvent $event) {
         // Set-up the IO for the Symfony Helper classes.
         if (!isset($this->container['console_io'])) {
             $io = $event->getIO();
             $args = $event->getArgs();
             $input = new ArgsInput($args->getRawArgs(), $args);
             $input->setInteractive($io->isInteractive());
             $this->container['console_io'] = $io;
             $this->container['console_args'] = $args;
             $this->container['sf.console_input'] = $input;
             $this->container['sf.console_output'] = new IOOutput($io);
         }
     });
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new ProjectDirectorySetupListener($this->container));
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new AutoLoadingSetupListener($this->container));
     $this->addEventListener(ConsoleEvents::PRE_HANDLE, new ExpressionFunctionsProviderSetupListener($this->container));
     $this->beginCommand('generate')->setDescription('Generates a new skeleton structure in the current directory')->addArgument('profile', Argument::OPTIONAL, 'The name of the profile')->addOption('all', null, Option::BOOLEAN, 'Ask all questions (including optional)')->addOption('dry-run', null, Option::BOOLEAN, 'Show what would have been executed, without actually executing')->setHandler(function () {
         return new Handler\GenerateCommandHandler($this->container['style'], $this->container['config'], $this->container['profile_config_resolver'], $this->container['answers_set_factory']);
     })->end()->beginCommand('profile')->setDescription('Manage the profiles of your project')->setHandler(function () {
         return new Handler\ProfileCommandHandler($this->container['style'], $this->container['profile_config_resolver'], $this->container['config']);
     })->beginSubCommand('list')->setHandlerMethod('handleList')->markDefault()->end()->beginSubCommand('show')->addArgument('name', Argument::OPTIONAL, 'The name of the profile')->setHandlerMethod('handleShow')->end()->end();
 }
Beispiel #2
0
 public function testSetInteractive()
 {
     $inputArgs = new ArgsInput($this->rawArgs, $this->args);
     $this->assertTrue($inputArgs->isInteractive());
     $inputArgs->setInteractive(false);
     $this->assertFalse($inputArgs->isInteractive());
 }