<commit_before><?php

namespace Isaac\Commands\Mods;

use Isaac\Services\Conflicts\Conflict;
use Symfony\Component\Console\Question\ChoiceQuestion;

/**
 * Copies non-LUA mods into your resource folder.
 */
class Install extends AbstractModsCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        return parent::configure()
            ->setName('mods:install')
            ->setDescription('Copies non-LUA mods into your resource folder');
    }

    /**
     * {@inheritdoc}
     */
    protected function fire()
    {
        $modsQueue = $this->getModsQueue();

        // Rename packed folder if necessary
        if (!$this->mods->areResourcesBackup()) {
            $this->output->writeln('<comment>Making a backup of resources folder, this only has to be done once</comment>');
            $this->mods->backup();
        }

        // Resolve eventual conflicts in the mods
        $modsQueue = $this->conflicts->findAndResolve($modsQueue, function (Conflict $conflict) {
            $this->output->writeln('<fg=red>Found conflicts for:</fg=red> '.$conflict->getPath());
            $this->output->caution('Note: Checking multiple can have unforeseen consequences');

            // Compute choices and resolutions
            $choices = $conflict->getPossibleChoices();
            $resolutions = $conflict->getPossibleResolutions();

            // Ask user to select which mods to use
            $question = new ChoiceQuestion('Which mod(s) would you like to use here?', $choices->all());
            $question->setMultiselect(true);
            $question->setAutocompleterValues($choices->keys());

            // Retrieve mod IDs from selection
            $resolution = (array) $this->output->askQuestion($question);
            foreach ($resolution as &$choice) {
                $choice = $resolutions->get($choice);
            }

            return $resolution;
        });

        // Present mods to install
        $this->presentMods('Installing', $modsQueue);
        $progress = $this->output->createProgressBar($modsQueue->count());
        $progress->setMessage('');
        $progress->setFormat(
            '%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'.PHP_EOL.PHP_EOL.'Installing <comment>%message%</comment>'
        );

        // Restore main.lua file
        $this->mods->restoreMainLua();
<commit_msg>Add precision about multiple choices<commit_after><?php

namespace Isaac\Commands\Mods;

use Isaac\Services\Conflicts\Conflict;
use Symfony\Component\Console\Question\ChoiceQuestion;

/**
 * Copies non-LUA mods into your resource folder.
 */
class Install extends AbstractModsCommand
{
    /**
     * {@inheritdoc}
     */
    protected function configure()
    {
        return parent::configure()
            ->setName('mods:install')
            ->setDescription('Copies non-LUA mods into your resource folder');
    }

    /**
     * {@inheritdoc}
     */
    protected function fire()
    {
        $modsQueue = $this->getModsQueue();

        // Rename packed folder if necessary
        if (!$this->mods->areResourcesBackup()) {
            $this->output->writeln('<comment>Making a backup of resources folder, this only has to be done once</comment>');
            $this->mods->backup();
        }

        // Resolve eventual conflicts in the mods
        $modsQueue = $this->conflicts->findAndResolve($modsQueue, function (Conflict $conflict) {
            $this->output->writeln('<fg=red>Found conflicts for:</fg=red> '.$conflict->getPath());
            $this->output->caution('Note: Checking multiple can have unforeseen consequences');

            // Compute choices and resolutions
            $choices = $conflict->getPossibleChoices();
            $resolutions = $conflict->getPossibleResolutions();

            // Ask user to select which mods to use
            $question = new ChoiceQuestion('Which mod(s) would you like to use here? Can use multiple answers (eg. 1,2,4)', $choices->all());
            $question->setMultiselect(true);
            $question->setAutocompleterValues($choices->keys());

            // Retrieve mod IDs from selection
            $resolution = (array) $this->output->askQuestion($question);
            foreach ($resolution as &$choice) {
                $choice = $resolutions->get($choice);
            }

            return $resolution;
        });

        // Present mods to install
        $this->presentMods('Installing', $modsQueue);
        $progress = $this->output->createProgressBar($modsQueue->count());
        $progress->setMessage('');
        $progress->setFormat(
            '%current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%'.PHP_EOL.PHP_EOL.'Installing <comment>%message%</comment>'
        );

        // Restore main.lua file
        $this->mods->restoreMainLua();

{'fraction_non_alphanumeric': 0.14229818780889622, 'fraction_numerical': 0.0018533772652388797, 'mean_word_length': 2.4892241379310347, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 81, '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': '5033423', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1318, 'n_words': 300}