/**
  * @throws InvalidCommitMessageException
  */
 public function validate()
 {
     $this->outputHandler->setTitle('Checking commit message');
     $this->outputHandler->getTitle();
     $commitMessage = $this->extractCommitMessage->extract($this->input->getFirstArgument());
     if (!$this->isValidMessage($commitMessage)) {
         throw new InvalidCommitMessageException();
     }
     $this->outputHandler->getSuccessfulStepMessage();
 }
Example #2
0
 protected function getCommandName(InputInterface $input)
 {
     if (!$input->hasParameterOption(array('--config', '-c')) && !$input->getFirstArgument()) {
         return 'list';
     }
     return 'logfilter';
 }
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $commandName = $input->getFirstArgument();
     $enable = false !== strpos($commandName, 'enable');
     $full = $input->getOption('full');
     $config = Config::getInstance();
     $development = $config->Development;
     if ($enable) {
         $development['enabled'] = 1;
         if ($full) {
             $development['disable_merged_assets'] = 1;
         }
         $message = 'Development mode enabled';
     } else {
         $development['enabled'] = 0;
         if ($full) {
             $development['disable_merged_assets'] = 0;
         }
         $message = 'Development mode disabled';
     }
     $config->Development = $development;
     $config->forceSave();
     Filesystem::deleteAllCacheOnUpdate();
     $this->writeSuccessMessage($output, array($message));
 }
Example #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':l')) {
         $output->writeln('<comment>The use of "yaml:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:yaml" instead.</comment>');
     }
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
         }
         $content = '';
         while (!feof(STDIN)) {
             $content .= fread(STDIN, 1024);
         }
         return $this->display($input, $output, array($this->validate($content)));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.yml');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.yml');
     }
     $filesInfo = array();
     foreach ($files as $file) {
         $filesInfo[] = $this->validate(file_get_contents($file), $file);
     }
     return $this->display($input, $output, $filesInfo);
 }
Example #5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stdout = $output;
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':l')) {
         $output->caution('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.');
     }
     $twig = $this->getTwigEnvironment();
     if (null === $twig) {
         $output->error('The Twig environment needs to be set.');
         return 1;
     }
     $filenames = $input->getArgument('filename');
     if (0 === count($filenames)) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
         }
         $template = '';
         while (!feof(STDIN)) {
             $template .= fread(STDIN, 1024);
         }
         return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_'))));
     }
     $filesInfo = $this->getFilesInfo($twig, $filenames);
     return $this->display($input, $stdout, $output, $filesInfo);
 }
Example #6
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->writeln('<comment>The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.</comment>');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $kernel = $this->getContainer()->get('kernel');
     $method = new \ReflectionMethod($kernel, 'buildContainer');
     $method->setAccessible(true);
     $container = $method->invoke($kernel);
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->writeln(sprintf('# Current configuration for extension with alias: "%s"', $name));
     } else {
         $output->writeln(sprintf('# Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
Example #7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->writeln('<comment>The use of "twig:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:twig" instead.</comment>');
     }
     parent::execute($input, $output);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->writeln('<comment>The use of "container:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:container" instead.</comment>');
     }
     $this->validateInput($input);
     if ($input->getOption('parameters')) {
         $object = $this->getContainerBuilder()->getParameterBag();
         $options = array();
     } elseif ($parameter = $input->getOption('parameter')) {
         $object = $this->getContainerBuilder();
         $options = array('parameter' => $parameter);
     } elseif ($input->getOption('tags')) {
         $object = $this->getContainerBuilder();
         $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private'));
     } elseif ($tag = $input->getOption('tag')) {
         $object = $this->getContainerBuilder();
         $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
     } elseif ($name = $input->getArgument('name')) {
         $object = $this->getContainerBuilder();
         $name = $this->findProperServiceName($input, $output, $object, $name);
         $options = array('id' => $name);
     } else {
         $object = $this->getContainerBuilder();
         $options = array('show_private' => $input->getOption('show-private'));
     }
     $helper = new DescriptorHelper();
     $options['format'] = $input->getOption('format');
     $options['raw_text'] = $input->getOption('raw');
     $helper->describe($output, $object, $options);
     if (!$input->getArgument('name') && $input->isInteractive()) {
         $output->writeln('To search for a service, re-run this command with a search term. <comment>debug:container log</comment>');
     }
 }
Example #9
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
Example #10
0
 /**
  * Gets the name of the command based on input.
  *
  * @param InputInterface $input The input interface
  *
  * @return string The command name
  */
 protected function getCommandName(InputInterface $input)
 {
     if ($input->getFirstArgument() === null && !$input->hasParameterOption(array('--help', '-h'))) {
         $this->isDefault = true;
         return $this->getDefaultCommandName();
     }
     return parent::getCommandName($input);
 }
Example #11
0
 protected function isCreate(InputInterface $input)
 {
     $cmd = explode(':', $input->getFirstArgument(), 2);
     if (substr_compare('create', $cmd[1], 0, strlen($cmd[1])) === 0) {
         return true;
     }
     return $input->getOption('create');
 }
Example #12
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $io->caution('The use of "twig:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:twig" instead.');
     }
     parent::execute($input, $io);
 }
Example #13
0
 /**
  * Runs the current application.
  *
  * Always show the version information except when the user invokes the help
  * command as that already does it
  *
  * @param InputInterface $input An Input instance
  * @param OutputInterface $output An Output instance
  * @return integer 0 if everything went fine, or an error code otherwise
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     if ($this->showWelcomeMessage && $input->hasParameterOption(array('--help', '-h')) === false && $input->getFirstArgument() !== null) {
         $output->writeln($this->getLongVersion());
         $output->writeln('');
     }
     return parent::doRun($input, $output);
 }
Example #14
0
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Tombstone Analyzer ' . $this->getVersion());
     if (!$input->getFirstArgument()) {
         $input = new ArrayInput(array('--help'));
     }
     AbstractApplication::doRun($input, $output);
 }
Example #15
0
 protected function getCommandName(InputInterface $input)
 {
     try {
         return $this->find('server:' . $input->getFirstArgument())->getName();
     } catch (CommandNotFoundException $e) {
         return parent::getCommandName($input);
     }
 }
Example #16
0
 /**
  * @param string[]       $args
  * @param InputInterface $input
  *
  * @return string[]
  */
 protected function stripArguments(array $args, InputInterface $input)
 {
     // Strip out the application name.
     array_shift($args);
     // Strip out the command name.
     if (($key = array_search($input->getFirstArgument(), $args)) !== false) {
         unset($args[$key]);
     }
     return $args;
 }
Example #17
0
 /**
  * Runs the current application.
  *
  * @param InputInterface $input An Input instance
  * @param OutputInterface $output An Output instance
  * @return integer 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     // always show the version information except when the user invokes the help
     // command as that already does it
     if (false === $input->hasParameterOption(array('--help', '-h')) && null !== $input->getFirstArgument()) {
         $output->writeln($this->getLongVersion());
         $output->writeln('');
     }
     return parent::doRun($input, $output);
 }
Example #18
0
 protected function getCommandName(InputInterface $input)
 {
     $command = $input->getFirstArgument();
     if (!$command && !$input->hasParameterOption('--help')) {
         return 'list';
     } elseif ($this->has($command)) {
         return $command;
     } else {
         $this->explicit = false;
         return 'highlight';
     }
 }
Example #19
0
 /**
  * @param InputInterface $input
  *
  * @throws InvalidCommitMessageException
  */
 public function run(InputInterface $input)
 {
     /** @var ConfigurationDataResponse $configurationDataResponse */
     $configurationDataResponse = $this->queryBus->handle(new ConfigurationDataFinderQuery());
     if (true === $configurationDataResponse->getCommitMsg()->isCommitMsg()) {
         $commitContent = $this->commitMessageFinder->find($input->getFirstArgument());
         $validMessage = $this->isValidCommitMessage($configurationDataResponse->getCommitMsg()->getRegularExpression(), $commitContent);
         if (false === $validMessage) {
             throw new InvalidCommitMessageException();
         }
     }
 }
 /**
  * Gets the name of the command based on input.
  *
  * @param InputInterface $input The input interface
  *
  * @return string The command name
  */
 protected function getCommandName(InputInterface $input)
 {
     $available = ['metrics', 'self-update', 'init'];
     $arg = $input->getFirstArgument();
     if (!in_array($arg, $available) || 'metrics' === $arg) {
         // default argument : we don't want to provide the name of the command by default
         $inputDefinition = $this->getDefinition();
         $inputDefinition->setArguments();
         $this->setDefinition($inputDefinition);
         return 'metrics';
     }
     return $arg;
 }
 /**
  * Runs the current application.
  *
  * @param InputInterface  $input  An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return int 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     if (!$input->hasParameterOption('--quiet')) {
         $output->write(sprintf("bugminer %s by Sebastian Bergmann.\n\n", $this->getVersion()));
     }
     if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
         exit;
     }
     if (!$input->getFirstArgument()) {
         $input = new ArrayInput(array('--help'));
     }
     parent::doRun($input, $output);
 }
Example #22
0
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     if (!$input->hasParameterOption('--quiet')) {
         $output->write(sprintf("<info>%s</info> by <comment>%s</comment> <%s>\n\n", self::APP_NAME, self::AUTHOR_NAME, self::AUTHOR_EMAIL));
     }
     if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
         return 0;
     }
     if (!$input->getFirstArgument()) {
         $input = new ArrayInput(['list']);
     }
     return parent::doRun($input, $output);
 }
 /**
  * Runs the current application.
  *
  * @param InputInterface  $input  An Input instance
  * @param OutputInterface $output An Output instance
  *
  * @return int 0 if everything went fine, or an error code
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->disableXdebug();
     if (!$input->hasParameterOption('--quiet')) {
         $output->write(sprintf("phar-site-generator %s by Sebastian Bergmann.\n\n", $this->getVersion()));
     }
     if ($input->hasParameterOption('--version') || $input->hasParameterOption('-V')) {
         exit;
     }
     if (!$input->getFirstArgument()) {
         $input = new ArrayInput(['--help']);
     }
     parent::doRun($input, $output);
 }
Example #24
0
 /**
  * Run the console application.
  *
  * @param  \Symfony\Component\Console\Input\InputInterface   $input
  * @param  \Symfony\Component\Console\Output\OutputInterface $output
  * @return int
  */
 public function handle($input, $output = null)
 {
     // The name of the command should be the first argument.
     $commandName = $input->getFirstArgument();
     if ($this->commandOverridesInputInterface($commandName)) {
         $inputClass = $this->commandInputOverrides[$commandName];
         $input = new $inputClass();
     }
     try {
         $this->bootstrap();
         return $this->getArtisan()->run($input, $output);
     } catch (Exception $e) {
         $this->reportException($e);
         $this->renderException($output, $e);
         return 1;
     }
 }
Example #25
0
 /**
  * alias magerun command in input from config
  *
  * @param InputInterface $input
  * @return ArgvInput|InputInterface
  */
 public function checkConfigCommandAlias(InputInterface $input)
 {
     foreach ($this->getArray(array('commands', 'aliases')) as $alias) {
         if (!is_array($alias)) {
             continue;
         }
         $aliasCommandName = key($alias);
         if ($input->getFirstArgument() !== $aliasCommandName) {
             continue;
         }
         $aliasCommandParams = array_slice(BinaryString::trimExplodeEmpty(' ', $alias[$aliasCommandName]), 1);
         if (count($aliasCommandParams) > 0) {
             // replace with aliased data
             $mergedParams = array_merge(array_slice($_SERVER['argv'], 0, 2), $aliasCommandParams, array_slice($_SERVER['argv'], 2));
             $input = new ArgvInput($mergedParams);
         }
     }
     return $input;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $style = new OutputFormatterStyle('black', 'cyan', []);
     $output->getFormatter()->setStyle('title', $style);
     $command_name = $input->getFirstArgument();
     $this->activeMenuItems = $command_name == $this->name ? [] : explode(':', $command_name);
     /** @var \DrupalCodeGenerator\Commands\BaseGenerator $generator_name */
     $generator_name = $this->selectGenerator($input, $output);
     if (!$generator_name) {
         return 0;
     }
     $command = $this->getApplication()->find($generator_name);
     $aliases = $command->getAliases();
     $header = sprintf('<info>Command:</info> <comment>%s</comment>', isset($aliases[0]) ? $aliases[0] : $generator_name);
     $output->writeln($header);
     $output->writeln(str_repeat('<comment>-</comment>', strlen(strip_tags($header))));
     // Run the generator.
     return $command->run($input, $output);
 }
Example #27
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When route does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->writeln('<comment>The use of "router:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:router" instead.</comment>');
     }
     $name = $input->getArgument('name');
     $helper = new DescriptorHelper();
     if ($name) {
         $route = $this->getContainer()->get('router')->getRouteCollection()->get($name);
         if (!$route) {
             throw new \InvalidArgumentException(sprintf('The route "%s" does not exist.', $name));
         }
         $this->convertController($route);
         $helper->describe($output, $route, array('format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'name' => $name));
     } else {
         $routes = $this->getContainer()->get('router')->getRouteCollection();
         foreach ($routes as $route) {
             $this->convertController($route);
         }
         $helper->describe($output, $routes, array('format' => $input->getOption('format'), 'raw_text' => $input->getOption('raw'), 'show_controllers' => $input->getOption('show-controllers')));
     }
 }
Example #28
0
 protected function executeDev(InputInterface $input, OutputInterface $output)
 {
     $manager = ProcessManager::create(\get_included_files()[0], 1);
     $manager->setEnv('K1_CONTEXT', 'development');
     $manager->setCommand($input->getFirstArgument());
     foreach ($input->getOptions() as $k => $v) {
         if ($k !== 'd' && $k !== 'dev') {
             $manager->setOption($k, $v);
         }
     }
     foreach (\array_slice($input->getArguments(), 1) as $arg) {
         $manager->addArgument($arg);
     }
     foreach ($this->boot->getObservedFiles() as $file) {
         $manager->observeFile($file);
     }
     foreach ($this->boot->getObservedDirectories() as $dir) {
         $manager->observeDirectory($dir);
     }
     $this->boot->run($this->container, function () use($manager) {
         $manager->run();
     });
 }
 /**
  * Gets the name of the command based on input.
  *
  * @param InputInterface $input The input interface
  *
  * @return string The command name
  */
 protected function getCommandName(InputInterface $input)
 {
     return $input->getFirstArgument();
 }
Example #30
0
 /**
  * {@inheritDoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     if (version_compare(PHP_VERSION, '5.3.2', '<')) {
         $output->writeln('<warning>Consolle only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP ' . PHP_VERSION . ', upgrading is strongly recommended.</warning>');
     }
     // Teste time to update
     if (defined('PHAR_DEV_WARNING_TIME')) {
         $commandName = '';
         if ($name = $input->getFirstArgument()) {
             try {
                 $commandName = $this->find($name)->getName();
             } catch (\InvalidArgumentException $e) {
             }
         }
         if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
             if (time() > PHAR_DEV_WARNING_TIME) {
                 $output->writeln(sprintf('Warning: This development build of %s is over 30 days old. It is recommended to update it by running "%s self-update" to get the latest version.', strtolower($this->name), $_SERVER['PHP_SELF']));
             }
         }
     }
     // switch working dir
     if ($newWorkDir = $this->getNewWorkingDir($input)) {
         $oldWorkingDir = getcwd();
         chdir($newWorkDir);
     }
     // Evento running
     \Event::fire('running', $this->version);
     $result = parent::doRun($input, $output);
     if (isset($oldWorkingDir)) {
         chdir($oldWorkingDir);
     }
     return $result;
 }