<commit_before><?php

namespace PHPCR\Util\Console\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\DialogHelper;

use PHPCR\Util\NodeHelper;
use PHPCR\Util\Console\Helper\ConsoleParametersParser;

/**
 * @author <NAME> <<EMAIL>>
 */
class PurgeCommand extends Command
{
    protected function configure()
    {
        parent::configure();

        $this->setName('phpcr:purge')
            ->setDescription('Remove all content from the repository')
            ->addOption('force', null, InputOption::VALUE_OPTIONAL, 'Set to "yes" to bypass the confirmation dialog', "no")
            ->setHelp(<<<EOF
The <info>phpcr:purge</info> command remove all the non-standard nodes from the content repository
EOF
        );
    }

    /**
     * Executes the current command.
     *
     * @param InputInterface  $input  An InputInterface instance
     * @param OutputInterface $output An OutputInterface instance
     *
     * @return integer 0 if everything went fine, or an error code
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $session = $this->getHelper('phpcr')->getSession();

        $force = ConsoleParametersParser::isTrueString($input->getOption('force'));

        if (! $force) {
            $dialog = new DialogHelper();
            $res = $dialog->askConfirmation($output, 'Are you sure you want to delete all the nodes of the content repository?', false); // TODO: output server and workspace name
        }

        if ($force || $res) {
            NodeHelper::deleteAllNodes($this->getHelper('phpcr')->getSession());
            $session->save();
            $output->writeln("Done\n");
        }

        return 0;
    }
}<commit_msg>make purge command dialog look nicer<commit_after><?php

namespace PHPCR\Util\Console\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\DialogHelper;

use PHPCR\Util\NodeHelper;
use PHPCR\Util\Console\Helper\ConsoleParametersParser;

/**
 * @author <NAME> <<EMAIL>>
 */
class PurgeCommand extends Command
{
    protected function configure()
    {
        parent::configure();

        $this->setName('phpcr:purge')
            ->setDescription('Remove all content from the repository')
            ->addOption('force', null, InputOption::VALUE_OPTIONAL, 'Set to "yes" to bypass the confirmation dialog', "no")
            ->setHelp(<<<EOF
The <info>phpcr:purge</info> command remove all the non-standard nodes from the content repository
EOF
        );
    }

    /**
     * Executes the current command.
     *
     * @param InputInterface  $input  An InputInterface instance
     * @param OutputInterface $output An OutputInterface instance
     *
     * @return integer 0 if everything went fine, or an error code
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $session = $this->getHelper('phpcr')->getSession();

        $force = ConsoleParametersParser::isTrueString($input->getOption('force'));

        if (! $force) {
            $dialog = new DialogHelper();
            $res = $dialog->askConfirmation($output, 'Are you sure you want to delete all the nodes of the content repository? [yes|no]: ', false); // TODO: output server and workspace name
        }

        if ($force || $res) {
            NodeHelper::deleteAllNodes($this->getHelper('phpcr')->getSession());
            $session->save();
            $output->writeln("Done\n");
        } else {
            $output->writeln("Aborted\n");
        }

        return 0;
    }
}
{'fraction_non_alphanumeric': 0.12365591397849462, 'fraction_numerical': 0.0010240655401945725, 'mean_word_length': 3.0445134575569357, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 38, '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': '1554336', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1037, 'n_words': 276}