protected function execute(InputInterface $input, OutputInterface $output) { $this->avail = new Availability(); $this->output = $output; $this->input = $input; $this->helper = $this->getHelper('question'); $this->checkMemoryLimit(); // Download list of all available languages and let user choose what they want. $this->output->writeln('Downloading ' . Availability::DOWNLOADS_URL); $this->allLanguages = $this->avail->listPackages(); $languages = $this->input->getOption('language') ? [$this->input->getOption('language')] : $this->chooseLanguages(); // Choose mirror. $mirror = $this->input->getOption('mirror') ?: $this->chooseMirror(); // Choose what to do with function examples. $includeExamples = $this->stringExamplesParamsToConst($this->input->getOption('examples') ?: $this->chooseIncludeExamples()); if (in_array('all', $languages)) { $languages = array_map(function ($code) { return $code; }, array_keys($this->allLanguages)); } $langTitles = array_map(function ($code) { return $this->allLanguages[$code]; }, $languages); $this->output->writeln('Selected language[s]: ' . implode(', ', array_map(function ($lang) { return '<info>' . $lang . '</info>'; }, $langTitles)) . " from <info>{$mirror}</info> mirror site.\n"); $this->output->writeln(''); // Create output directory. $outDir = $this->input->getOption('out-dir'); @mkdir($outDir, 0777, true); if (!is_dir($outDir)) { $this->output->writeln("<error>Unable to create \"{$outDir}\" directory</error>"); return 1; } elseif (!is_writable($outDir)) { $this->output->writeln("<error>Directory \"{$outDir}\" directory isn't writable.</error>"); return 1; } // Download, unpack and parse this language. $mirror = preg_replace('/^(http:\\/\\/|https:\\/\\/)/', '', $mirror); foreach ($languages as $code) { $package = new Package($code, $mirror); $this->downloadPackage($package); $this->unpackPackage($package); // $results = $this->process($unpackedDir, $includeExamples); $this->parse($package, $outDir, $includeExamples); $package->cleanup(); } }
/** * @When /^I want a list all available languages$/ */ public function iWantAListAllAvailableLanguages() { $avail = new Availability(); $this->languages = $avail->listPackages(); }