<commit_before><?php namespace Orchestra\Extension\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class ExtensionCommand extends Command {
	
	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'orchestra:extension';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Orchestra\Extension Command';

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		$fired = false;
		$name  = $this->argument('name');

		switch ($action = $this->argument('action'))
		{
			case 'install' :
				# passthru;
			case 'upgrade' :
				$this->fireMigration();
				$this->info('orchestra/extension has been migrated');
				$fired = true;
				break;
			case 'detect' :
				$this->fireDetect();
				$fired = true;
				break;
			case 'activate' :
				$this->fireActivate($name);
				$fired = true;
				break;
			case 'deactivate' :
				$this->fireDeactivate($name);
				$fired = true;
				break;
		}

		if ($fired === false) return $this->error("Invalid action [{$action}].");

		$this->laravel['orchestra.memory']->finish();
	}

	/**
	 * Fire migration process.
	 *
	 * @return void
	 */
	protected function fireMigration()
	{
		$this->call('migrate', array('--package' => 'orchestra/memory'));
	}

	/**
	 * Fire extension detection.
	 *
	 * @return void
	 */
	protected function fireDetect()
	{
		$service    = $this->laravel['orchestra.extension'];
		$extensions = $service->detect();

		if (empty($extensions))
		{
			return $this->line("<comment>No extension detected!</comment>");
		}

		$this->line("<info>Detected:</info>");

		foreach ($extensions as $name => $options)
		{
			$output = ($service->started($name) ? "✓ <info>%s %s</info>" : "- <comment>%s</comment>");
			
			$this->line(sprintf($output, $name, $options['version']));
		}
	}

	/**
	 * Fire extension activation.
	 *
	 * @param  string   $name
	 * @return void
	 */
	protected function fireActivate($name)
	{
		$this->laravel['orchestra.extension']->activate($name);
		$this->info("Extension [{$name}] activated.");
	}

	/**
	 * Fire extension activation.<commit_msg>Tweak console response for 'artisan orchestra:extension detect'<commit_after><?php namespace Orchestra\Extension\Console;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class ExtensionCommand extends Command {
	
	/**
	 * The console command name.
	 *
	 * @var string
	 */
	protected $name = 'orchestra:extension';

	/**
	 * The console command description.
	 *
	 * @var string
	 */
	protected $description = 'Orchestra\Extension Command';

	/**
	 * Create a new command instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		parent::__construct();
	}

	/**
	 * Execute the console command.
	 *
	 * @return void
	 */
	public function fire()
	{
		$fired = false;
		$name  = $this->argument('name');

		switch ($action = $this->argument('action'))
		{
			case 'install' :
				# passthru;
			case 'upgrade' :
				$this->fireMigration();
				$this->info('orchestra/extension has been migrated');
				$fired = true;
				break;
			case 'detect' :
				$this->fireDetect();
				$fired = true;
				break;
			case 'activate' :
				$this->fireActivate($name);
				$fired = true;
				break;
			case 'deactivate' :
				$this->fireDeactivate($name);
				$fired = true;
				break;
		}

		if ($fired === false) return $this->error("Invalid action [{$action}].");

		$this->laravel['orchestra.memory']->finish();
	}

	/**
	 * Fire migration process.
	 *
	 * @return void
	 */
	protected function fireMigration()
	{
		$this->call('migrate', array('--package' => 'orchestra/memory'));
	}

	/**
	 * Fire extension detection.
	 *
	 * @return void
	 */
	protected function fireDetect()
	{
		$service    = $this->laravel['orchestra.extension'];
		$extensions = $service->detect();

		if (empty($extensions))
		{
			return $this->line("<comment>No extension detected!</comment>");
		}

		$this->line("<info>Detected:</info>");

		foreach ($extensions as $name => $options)
		{
			$output = ($service->started($name) ? "✓ <info>%s [%s]</info>" : "- <comment>%s [%s]</comment>");
			
			$this->line(sprintf($output, $name, $options['version']));
		}
	}

	/**
	 * Fire extension activation.
	 *
	 * @param  string   $name
	 * @return void
	 */
	protected function fireActivate($name)
	{
		$this->laravel['orchestra.extension']->activate($name);
		$this->info("Extension [{$name}] activated.");
	}

	/**
	 * Fire extension activation.
{'fraction_non_alphanumeric': 0.18021424070573408, 'fraction_numerical': 0.0, 'mean_word_length': 3.3688073394495412, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 63, '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': '8505', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1507, 'n_words': 326}