Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for all commands and perform some minor code cleanup/maintenance #86

Merged
merged 2 commits into from
Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/Clue/PharComposer/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function __construct()
$this->add(new Command\Build());
$this->add(new Command\Search());
$this->add(new Command\Install());

// GUI feature disabled for now, see #35
// $this->add(new Command\Gui());
}

/**
Expand All @@ -32,20 +29,11 @@ protected function getCommandName(InputInterface $input)
{
if ($input->getFirstArgument() === null && !$input->hasParameterOption(array('--help', '-h'))) {
$this->isDefault = true;
return $this->getDefaultCommandName();
return 'search';
}
return parent::getCommandName($input);
}

private function getDefaultCommandName()
{
$gui = $this->has('gui') ? $this->get('gui') : null;
if ($gui instanceof Command\Gui && $gui->hasZenity()) {
return 'gui';
}
return 'search';
}

/**
* Overridden so that the application doesn't expect the command
* name to be the first argument.
Expand Down
38 changes: 19 additions & 19 deletions src/Clue/PharComposer/Command/Build.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

namespace Clue\PharComposer\Command;

use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Helper\DialogHelper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Clue\PharComposer\Phar\Packager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Clue\PharComposer\Phar\PharComposer;
use InvalidArgumentException;
use UnexpectedValueException;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ExecutableFinder;
use Clue\PharComposer\Phar\Packager;

class Build extends Command
{
/** @var Packager */
private $packager;

public function __construct(Packager $packager = null)
{
parent::__construct();

if ($packager === null) {
$packager = new Packager();
}
$this->packager = $packager;
}

protected function configure()
{
$this->setName('build')
->setDescription('Build phar for the given composer project')
->addArgument('path', InputArgument::OPTIONAL, 'Path to project directory or composer.json', '.')
->addArgument('project', InputArgument::OPTIONAL, 'Path to project directory or composer.json', '.')
->addArgument('target', InputArgument::OPTIONAL, 'Path to write phar output to (defaults to project name)');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$packager = new Packager();
$packager->setOutput(function ($line) use ($output) {
$output->write($line);
});

$packager->coerceWritable();
$this->packager->setOutput($output);
$this->packager->coerceWritable();

$pharer = $packager->getPharer($input->getArgument('path'));
$pharer = $this->packager->getPharer($input->getArgument('project'));

$target = $input->getArgument('target');
if ($target !== null) {
Expand Down
283 changes: 0 additions & 283 deletions src/Clue/PharComposer/Command/Gui.php

This file was deleted.

Loading