protected function execute(InputInterface $input, OutputInterface $output) { $packager = new Packager(); $packager->setOutput($output); $packager->coerceWritable(); $dialog = $this->getHelperSet()->get('dialog'); /* @var $dialog DialogHelper */ $name = $input->getArgument('name'); do { if ($name === null) { // ask for input $name = $dialog->ask($output, 'Enter (partial) project name > '); } else { $output->writeln('Searching for <info>' . $name . '</info>...'); } $packagist = new Client(); $choices = array(); foreach ($packagist->search($name) as $package) { /* @var $package Result */ $label = str_pad($package->getName(), 39) . ' '; $label = str_replace($name, '<info>' . $name . '</info>', $label); $label .= $package->getDescription(); $label .= ' (⤓' . $package->getDownloads() . ')'; $choices[$package->getName()] = $label; } $name = $this->select($output, 'Select matching package', $choices, 'Start new search'); } while ($name === null); $output->writeln('Selected <info>' . $name . '</info>, listing versions...'); $package = $packagist->get($name); /* @var $package Package */ $choices = array(); foreach ($package->getVersions() as $version) { /* @var $version Version */ $label = $version->getVersion(); $bin = $version->getBin(); if ($bin === null) { $label .= ' (<error>no executable bin</error>)'; } else { $label .= ' (☑ executable bin)'; } $choices[$version->getVersion()] = $label; } $version = $this->select($output, 'Select available version', $choices); $action = $this->select($output, 'Action', array('build' => 'Build project', 'install' => 'Install project system-wide'), 'Quit'); if ($action === null) { return; } $pharer = $packager->getPharer($name, $version); if ($action === 'install') { $path = $packager->getSystemBin($pharer); $packager->install($pharer, $path); } else { $pharer->build(); } }
protected function execute(InputInterface $input, OutputInterface $output) { $packager = new Packager(); $packager->setOutput(function ($line) use($output) { $output->write($line); }); $packager->coerceWritable(); $pharer = $packager->getPharer($input->getArgument('path')); $target = $input->getArgument('target'); if ($target !== null) { $pharer->setTarget($target); } $pharer->build(); }
protected function execute(InputInterface $input, OutputInterface $output) { $packager = new Packager(); $packager->setOutput($output); $packager->coerceWritable(); $pharer = $packager->getPharer($input->getArgument('name')); $path = $packager->getSystemBin($pharer, $input->getArgument('path')); if (is_file($path)) { $dialog = $this->getHelperSet()->get('dialog'); /* @var $dialog DialogHelper */ if (!$dialog->askConfirmation($output, 'Overwrite existing file <info>' . $path . '</info>? [y] > ')) { $output->writeln('Aborting'); return; } } $packager->install($pharer, $path); }