<commit_before><?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Ballen\Executioner\Executer;

class FactoryResetCommand extends Command
{

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'turbine:factoryreset';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Restores the local DB back to default settings';

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

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        if ($this->confirm('Are you sure you wish to restore to factory defaults? [y/N] ', false)) {

// Execute the migration tasks here, meaning that we only have to keep the migrations up to date and the rest should
            // just work :)
            $app_path = str_replace('/app/commands', '', dirname(__FILE__));
            $execute = new Executer;
            $execute->setApplication('php')->addArgument($app_path . '/artisan')->addArgument('migrate:refresh')->addArgument('--seed');
            $execute->execute();
            foreach ($execute->resultAsArray() as $outputline) {
                $this->info($outputline);
            }

            Log::alert('Factory settings restored from the console.');
            $this->info('Database settings restored!');
        } else {
            $this->error('User cancelled!');
        }
    }

    /**
     * Get the console command arguments.
     *
     * @return array<commit_msg>Updated FactoryResetCommand so that a new API key is generated following successful revert of the database.<commit_after><?php

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Ballen\Executioner\Executer;

class FactoryResetCommand extends Command
{

    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'turbine:factoryreset';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Restores the local DB back to default settings';

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

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        if ($this->confirm('Are you sure you wish to restore to factory defaults? [y/N] ', false)) {

            /**
             * Execute the migration tasks here, meaning that we only have to keep the migrations
             *  up to date and the rest should just work :)
             */
            $app_path = str_replace('/app/commands', '', dirname(__FILE__));
            $execute = new Executer;
            $execute->setApplication('php')->addArgument($app_path . '/artisan')->addArgument('migrate:refresh')->addArgument('--seed')->execute();
            $genkey = new Executer;
            $genkey->setApplication('php')->addArgument($app_path . '/artisan')->addArgument('turbine:generatekey')->execute();
            /**
             *  Users can uncommet this code block if they want verbose factory resets!
             *
             * foreach ($execute->resultAsArray() as $outputline) {
             *    $this->info($outputline); - Users can uncommet this if they want verbose factory resets!
             * }
             *
             */
            Log::alert('Factory settings restored from the console');
            $this->info('Factory settings restored and a new API key has been generated!');
        } else {
            $this->error('User cancelled!');
        }
    }

    /**
     * Get the console command arguments.
     *
     * @return array
{'fraction_non_alphanumeric': 0.12025948103792415, 'fraction_numerical': 0.0, 'mean_word_length': 2.1467817896389323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '803882', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1035, 'n_words': 302}