<commit_before><?php namespace Rancherize\Commands;
use Rancherize\Commands\Traits\EnvironmentTrait;
use Rancherize\Commands\Traits\IoTrait;
use Rancherize\Configuration\Configurable;
use Rancherize\Configuration\Services\ConfigWrapper;
use Rancherize\Configuration\Traits\EnvironmentConfigurationTrait;
use Rancherize\Configuration\Traits\LoadsConfigurationTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

/**
 * Class EnvironmentAddCommand
 * @package Rancherize\Commands
 */
class EnvironmentSetCommand extends Command {

	use IoTrait;
	use LoadsConfigurationTrait;
	use EnvironmentTrait;
	use EnvironmentConfigurationTrait;

	protected function configure() {
		$this->setName('environment:set')
			->setDescription('Add a given environment value to all app environments')
			->addArgument('name', InputArgument::REQUIRED)
			->addArgument('value', InputArgument::OPTIONAL)
			->addOption('global', 'g', InputOption::VALUE_NONE)
		;
		parent::configure();
	}

	/**
	 * @param InputInterface $input
	 * @param OutputInterface $output
	 * @return int|null|void
	 */
	protected function execute(InputInterface $input, OutputInterface $output) {

		$this->setIo($input, $output);

		$configuration = $this->loadConfiguration();

		$this->setVariable($input, $output, $configuration);

		$environments = $this->getEnvironmentService()->allAvailable($configuration);


		/**
		 * @var ConfigWrapper $configWrapper
		 */
		$configWrapper = container('config-wrapper');
		$configWrapper->saveProjectConfig($configuration);
	}

	/**
	 * @param InputInterface $input
	 * @param OutputInterface $output
	 * @param $configuration
	 */
	protected function setVariable(InputInterface $input, OutputInterface $output, Configurable $configuration) {

		$name = $input->getArgument('name');

		if ( $input->getOption('global') ) {

			$question = new Question('Please enter the value for the global environment variable ' . $name);
			$value = $this->getHelper('question')->ask($input, $output, $question);

			$configuration->set("project.$name", $value);

			return;
		}

		$environments = $this->getEnvironmentService()->allAvailable($configuration);
		foreach($environments as $environment) {

			$environmentConfig = $this->environmentConfig($configuration, $environment);

			$output->writeln( $output->getFormatter()->format("<info>$environment</info>") );
			$currentValue = $environmentConfig->get($name);
			$question = new Question("Please enter the value for the Environment Variable $environment.$name ($currentValue): ", $currentValue);
			$value = $this->getHelper('question')->ask($input, $output, $question);

			$output->writeln( $output->getFormatter()->format("Setting <info>project.environments.$environment.$name</info> to <info>$value</info>"), OutputInterface::VERBOSITY_VERBOSE );
			$configuration->set("project.environments.$environment.$name", $value);
		}
<commit_msg>removed global option for environment setting and corrected environment set path<commit_after><?php namespace Rancherize\Commands;
use Rancherize\Commands\Traits\EnvironmentTrait;
use Rancherize\Commands\Traits\IoTrait;
use Rancherize\Configuration\Configurable;
use Rancherize\Configuration\Services\ConfigWrapper;
use Rancherize\Configuration\Traits\EnvironmentConfigurationTrait;
use Rancherize\Configuration\Traits\LoadsConfigurationTrait;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

/**
 * Class EnvironmentAddCommand
 * @package Rancherize\Commands
 */
class EnvironmentSetCommand extends Command {

	use IoTrait;
	use LoadsConfigurationTrait;
	use EnvironmentTrait;
	use EnvironmentConfigurationTrait;

	protected function configure() {
		$this->setName('environment:set')
			->setDescription('Add a given environment value to all app environments')
			->addArgument('name', InputArgument::REQUIRED)
			->addArgument('value', InputArgument::OPTIONAL);
		;
		parent::configure();
	}

	/**
	 * @param InputInterface $input
	 * @param OutputInterface $output
	 * @return int|null|void
	 */
	protected function execute(InputInterface $input, OutputInterface $output) {

		$this->setIo($input, $output);

		$configuration = $this->loadConfiguration();

		$this->setVariable($input, $output, $configuration);

		/**
		 * @var ConfigWrapper $configWrapper
		 */
		$configWrapper = container('config-wrapper');
		$configWrapper->saveProjectConfig($configuration);

		return 0;
	}

	/**
	 * @param InputInterface $input
	 * @param OutputInterface $output
	 * @param $configuration
	 */
	protected function setVariable(InputInterface $input, OutputInterface $output, Configurable $configuration) {

		$name = $input->getArgument('name');

		$environments = $this->getEnvironmentService()->allAvailable($configuration);
		foreach($environments as $environment) {

			$environmentConfig = $this->environmentConfig($configuration, $environment);

			$output->writeln( $output->getFormatter()->format("<info>$environment</info>") );

			$currentValue = $environmentConfig->get("environment.$name");
			$question = new Question("Please enter the value for the Environment Variable $environment.$name ($currentValue): ", $currentValue);
			$value = $this->getHelper('question')->ask($input, $output, $question);

			$output->writeln( $output->getFormatter()->format("Setting <info>project.environments.$environment.$name</info> to <info>$value</info>"), OutputInterface::VERBOSITY_VERBOSE );
			$configuration->set("project.environments.$environment.environment.$name", $value);
		}

{'fraction_non_alphanumeric': 0.13765182186234817, 'fraction_numerical': 0.00016869095816464237, 'mean_word_length': 6.195388349514563, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 66, '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': '1066942', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1593, 'n_words': 322}