<commit_before><?php
/* (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Console;

use Deployer\Deployer;
use Deployer\Environment;
use Deployer\Server\DryRun;
use Deployer\Server\ServerInterface;
use Deployer\Stage\Stage;
use Deployer\Task\AbstractTask;
use Deployer\Task\Runner;
use Deployer\Task\TaskInterface;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class RunTaskCommand extends BaseCommand
{
    /**
     * @var TaskInterface
     */
    private $task;

    /**
     * @var Deployer
     */
    private $deployer;

    /**
     * @param null|string $name
     * @param TaskInterface $task
     */
    public function __construct($name, TaskInterface $task, Deployer $deployer)
    {
        parent::__construct($name);
        $this->task = $task;
        $this->deployer = $deployer;

        if ($task instanceof AbstractTask) {
            $this->setDescription($task->getDescription());
        }

        $this->addOption(
            'dry-run',
            null,
            InputOption::VALUE_NONE,
            'Run without execution command on servers.'
        );

        $this->addArgument(
            'stage',
            InputArgument::OPTIONAL,
            'Run tasks for a specific environment',
            $deployer->getDefaultStage()
        );

        $this->addOption(
            'dry-run',
            null,
            InputOption::VALUE_NONE,
            'Run without execution command on servers.'
        );

        $this->addOption(
            'server',
            null,
            InputOption::VALUE_OPTIONAL,
            'Run tasks only on ths server.'
        );

        if ($task instanceof AbstractTask) {
            foreach ($task->getOptions() as $option) {
                $this->getDefinition()->addOption($option);
            }
        }
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Configure deployer to dry run.
        if ($input->getOption('dry-run')) {
            // Nothing to do now.
        }

        $servers = $this->deployer->getServers();

        if ($this->deployer->getMultistage()) {

            if (null === $input->getArgument('stage')) {
                throw new \InvalidArgumentException('You have turned on multistage support, but not defined a stage (or default stage).');
            }
<commit_msg>RunTaskCommand: add option to not give ssh passphrase<commit_after><?php
/* (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Deployer\Console;

use Deployer\Deployer;
use Deployer\Environment;
use Deployer\Server\DryRun;
use Deployer\Server\ServerInterface;
use Deployer\Stage\Stage;
use Deployer\Task\AbstractTask;
use Deployer\Task\Runner;
use Deployer\Task\TaskInterface;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class RunTaskCommand extends BaseCommand
{
    /**
     * @var TaskInterface
     */
    private $task;

    /**
     * @var Deployer
     */
    private $deployer;

    /**
     * @param null|string $name
     * @param TaskInterface $task
     */
    public function __construct($name, TaskInterface $task, Deployer $deployer)
    {
        parent::__construct($name);
        $this->task = $task;
        $this->deployer = $deployer;

        if ($task instanceof AbstractTask) {
            $this->setDescription($task->getDescription());
        }

        $this->addOption(
            'dry-run',
            null,
            InputOption::VALUE_NONE,
            'Run without execution command on servers.'
        );

        $this->addArgument(
            'stage',
            InputArgument::OPTIONAL,
            'Run tasks for a specific environment',
            $deployer->getDefaultStage()
        );

        $this->addOption(
            'no-passphrase',
            null,
            InputOption::VALUE_NONE,
            'Do not ask passphrase for ssh connection.'
        );

        $this->addOption(
            'server',
            null,
            InputOption::VALUE_OPTIONAL,
            'Run tasks only on ths server.'
        );

        if ($task instanceof AbstractTask) {
            foreach ($task->getOptions() as $option) {
                $this->getDefinition()->addOption($option);
            }
        }
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Configure deployer to dry run.
        if ($input->getOption('dry-run')) {
            // Nothing to do now.
        }

        $servers = $this->deployer->getServers();

        if ($this->deployer->getMultistage()) {

            if (null === $input->getArgument('stage')) {
                throw new \InvalidArgumentException('You have turned on multistage support, but not defined a stage (or default stage).');
            }

{'fraction_non_alphanumeric': 0.11412241887905605, 'fraction_numerical': 0.0, 'mean_word_length': 2.200589970501475, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 45, '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': '7224382', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1458, 'n_words': 362}