<commit_before><?php

namespace Akeneo\WatchExtension\Command;

use PhpSpec\Console\Command\RunCommand as BaseRunCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Lurker\ResourceWatcher;
use Lurker\Event\FilesystemEvent;
use Symfony\Component\Process\Process;

class RunCommand extends BaseRunCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        parent::configure();

        $this->addOption('watch', null, InputOption::VALUE_NONE, 'Rerun specs automatically on file changes');
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('watch'))
        {
            return parent::execute($input, $output);
        }

        $watcher = new ResourceWatcher;
        $watcher->track('phpspec.specifications', 'spec/', FilesystemEvent::MODIFY);
        $watcher->track('phpspec.sources', 'src/', FilesystemEvent::MODIFY);

        $watcher->addListener('all', function (FilesystemEvent $event) use ($input, $output) {
            $process = new Process(sprintf(
                'clear && phpspec run -y --ansi %s',
                $event->getResource()
            ));
            $process->run();
            $output->writeln($process->getOutput());
        });

        $watcher->start();
    }
}<commit_msg>Supported format and verbose options<commit_after><?php

namespace Akeneo\WatchExtension\Command;

use PhpSpec\Console\Command\RunCommand as BaseRunCommand;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Lurker\ResourceWatcher;
use Lurker\Event\FilesystemEvent;
use Symfony\Component\Process\Process;

class RunCommand extends BaseRunCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        parent::configure();

        $this->addOption('watch', null, InputOption::VALUE_NONE, 'Rerun specs automatically on file changes');
    }

    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('watch')) {
            return parent::execute($input, $output);
        }

        $watcher = new ResourceWatcher;
        $watcher->track('phpspec.specifications', 'spec/', FilesystemEvent::MODIFY);
        $watcher->track('phpspec.sources', 'src/', FilesystemEvent::MODIFY);

        $watcher->addListener('all', function (FilesystemEvent $event) use ($input, $output) {
            $options = '';
            if ($format = $input->getOption('format')) {
                $options = sprintf(' -f%s', $format);
            }
            if ($input->getOption('verbose')) {
                $options .= ' -v';
            }
            $process = new Process(sprintf(
                'clear && phpspec run -y --ansi%s %s',
                $options,
                $event->getResource()
            ));
            $process->run();
            $output->writeln($process->getOutput());
        });

        $watcher->start();
    }
}
{'fraction_non_alphanumeric': 0.1419753086419753, 'fraction_numerical': 0.0, 'mean_word_length': 2.6212290502793296, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883569', 'n_tokens_mistral': 911, 'n_tokens_neox': 896, 'n_words': 173}