<commit_before><?php
namespace PhpBrew\Command;

use Exception;
use PhpBrew\Config;
use PhpBrew\Builder;
use PhpBrew\VariantParser;
use PhpBrew\VariantBuilder;
use PhpBrew\Tasks\DownloadTask;
use PhpBrew\Tasks\PrepareDirectoryTask;
use PhpBrew\Tasks\MakeCleanTask;
use PhpBrew\Tasks\CleanTask;
use PhpBrew\Tasks\InstallTask;
use PhpBrew\Tasks\ExtractTask;
use PhpBrew\Tasks\ConfigureTask;
use PhpBrew\Tasks\BuildTask;
use PhpBrew\Tasks\DSymTask;
use PhpBrew\Tasks\TestTask;
use CLIFramework\ValueCollection;
use PhpBrew\Build;
use PhpBrew\Utils;
use PhpBrew\ReleaseList;
use CLIFramework\Command;

/*
 * TODO: refactor tasks to Task class.
 */

class InstallCommand extends Command
{
    public function brief()
    {
        return 'Install php';
    }

    public function aliases() {
        return array('i','ins');
    }

    public function usage()
    {
        return 'phpbrew install [php-version] ([+variant...])';
    }

    public function arguments($args) {
        $args->add('version')->suggestions(function() {
            $releaseList = ReleaseList::getReadyInstance();
            $releases = $releaseList->getReleases();

            $collection = new ValueCollection;
            foreach($releases as $major => $versions) {
                $collection->group($major, "PHP $major", array_keys($versions));
            }
            return $collection;
        });
        $args->add('variants')->multiple()->suggestions(function() {
            $variants = new VariantBuilder;
            $list = $variants->getVariantNames();
            sort($list);
            return array_map(function($n) { return '+' . $n; }, $list);
        });
    }

    /**
     * @param \GetOptionKit\OptionCollection $opts
     */
    public function options($opts)
    {
        $opts->add('test', 'Run tests after the installation.');

        $opts->add('alias:', 'The alias of the installation')->valueName('alias');

        $opts->add('mirror:', 'Use mirror specific site.');

        $opts->add('post-clean', 'Run make clean after building PHP.');

        $opts->add('production', 'Use production configuration');

        $opts->add('build-dir:','Specify the build directory')
            ->isa('dir')
            ;

        $opts->add('no-clean', 'Do not clean previously compiled objects before building PHP.')
            ;

        $opts->add('no-patch', 'Do not apply any patch')
            ;

        $opts->add('no-configure', 'Do not run configure script')
            ;

        $opts->add('no-install', 'Do not install, just run build the target')
            ;


        $opts->add('n|nice:', 'Runs build processes at an altered scheduling priority.')
            ->valueName('priority')
            ;

        $opts->add('patch+:', 'Apply patch before build.')
            ->isa('file')
            ;

        $opts->add('old', 'Install phpbrew incompatible phps (< 5.3)');

        $opts->add('f|force', 'Force the installation.');

        $opts->add('d|dryrun', 'Do not build, but run through all the tasks.');

        $opts->add('like:', 'Inherit variants from an existing build')
            ->valueName('version');

        $opts->add('j|jobs:', 'Specifies the number of jobs to run simultaneously (make -jN).')
            ->valueName('concurrent job number')
            ;
    }

    public function execute($version)
    {<commit_msg>Add more detailed option description.<commit_after><?php
namespace PhpBrew\Command;

use Exception;
use PhpBrew\Config;
use PhpBrew\Builder;
use PhpBrew\VariantParser;
use PhpBrew\VariantBuilder;
use PhpBrew\Tasks\DownloadTask;
use PhpBrew\Tasks\PrepareDirectoryTask;
use PhpBrew\Tasks\MakeCleanTask;
use PhpBrew\Tasks\CleanTask;
use PhpBrew\Tasks\InstallTask;
use PhpBrew\Tasks\ExtractTask;
use PhpBrew\Tasks\ConfigureTask;
use PhpBrew\Tasks\BuildTask;
use PhpBrew\Tasks\DSymTask;
use PhpBrew\Tasks\TestTask;
use CLIFramework\ValueCollection;
use PhpBrew\Build;
use PhpBrew\Utils;
use PhpBrew\ReleaseList;
use CLIFramework\Command;

/*
 * TODO: refactor tasks to Task class.
 */

class InstallCommand extends Command
{
    public function brief()
    {
        return 'Install php';
    }

    public function aliases() {
        return array('i','ins');
    }

    public function usage()
    {
        return 'phpbrew install [php-version] ([+variant...])';
    }

    public function arguments($args) {
        $args->add('version')->suggestions(function() {
            $releaseList = ReleaseList::getReadyInstance();
            $releases = $releaseList->getReleases();

            $collection = new ValueCollection;
            foreach($releases as $major => $versions) {
                $collection->group($major, "PHP $major", array_keys($versions));
            }
            return $collection;
        });
        $args->add('variants')->multiple()->suggestions(function() {
            $variants = new VariantBuilder;
            $list = $variants->getVariantNames();
            sort($list);
            return array_map(function($n) { return '+' . $n; }, $list);
        });
    }

    /**
     * @param \GetOptionKit\OptionCollection $opts
     */
    public function options($opts)
    {
        $opts->add('test', 'Run tests after the installation.');

        $opts->add('alias:', 'The alias of the installation. By default the installed path is equal to the release version name (php-5.x.x), however you can specify whatever name you want instead of the default `php-5.x.x`. For example, `myphp-5.3.2-dbg`')
            ->valueName('alias');

        $opts->add('mirror:', 'Use specified mirror site. phpbrew will download the files from [mirror]/distributions/*');

        $opts->add('post-clean', 'Run make clean after the installation.');

        $opts->add('production', 'Use production configuration file. this installer will copy the php-production.ini into the etc directory.');

        $opts->add('build-dir:','Specify the build directory. '
            . 'the distribution tarball will be extracted to the directory you specified '
            . 'instead of $PHPBREW_ROOT/build/{version}.')
            ->isa('dir')
            ;

        $opts->add('no-clean', 'Do not clean previously compiled objects before building PHP. ' 
            . 'By default phpbrew will run `make clean` before runnign the configure script '
            . 'to ensure everything is cleaned up.')
            ;

        $opts->add('no-patch', 'Do not apply any patch')
            ;

        $opts->add('no-configure', 'Do not run configure script')
            ;

        $opts->add('no-install', 'Do not install, just run build the target')
            ;


        $opts->add('n|nice:', 'Runs build processes at an altered scheduling priority.')
            ->valueName('priority')
            ;

        $opts->add('patch+:', 'Apply patch before build.')
            ->isa('file')
            ;

        $opts->add('old', 'Install phpbrew incompatible phps (< 5.3)');

        $opts->add('f|force', 'Force the installation.');

        $opts->add('d|dryrun', 'Do not build, but run through all the tasks.');

        $opts->add('like:', 'Inherit variants from an existing build. This option would require an existing build directory from the {version}.')
            ->valueName('version');

        $opts->add('j|jobs:', 'Specifies the number of jobs to run build simultaneously (make -jN).')
            ->valueName('concurrent job number')
            ;
    }

    public function execute($version)
    {
{'fraction_non_alphanumeric': 0.13974615898463594, 'fraction_numerical': 0.0012024048096192384, 'mean_word_length': 2.557984790874525, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1067834', 'n_tokens_mistral': 2179, 'n_tokens_neox': 2115, 'n_words': 568}