Skip to content

Commit

Permalink
Merge branch 'release/2.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mblaschke committed Jul 17, 2015
2 parents 6d062b1 + 6b47cfe commit 64761a4
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 36 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CliTools Changelog
==================

2.1.1 - 2015-07-17
------------------
- Fixed `php:composer` global command usage
- Fixed `system:startup` terminal title in /etc/issue
- Updated to Symfony 2.7.2
- SLOC: 6,050

2.1.0 - 2015-07-08
------------------
- Added option `docker:create --up` for automatic startup
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CliTools for Docker, PHP und MySQL development

[![latest v2.1.0](https://img.shields.io/badge/latest-v2.1.0-green.svg?style=flat)](https://github.com/mblaschke/clitools/releases/tag/2.1.0)
[![latest v2.1.1](https://img.shields.io/badge/latest-v2.1.1-green.svg?style=flat)](https://github.com/mblaschke/clitools/releases/tag/2.1.1)
[![License GPL3](https://img.shields.io/badge/license-GPL3-blue.svg?style=flat)](/LICENSE)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/mblaschke/clitools.svg)](http://isitmaintained.com/project/mblaschke/clitools "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/mblaschke/clitools.svg)](http://isitmaintained.com/project/mblaschke/clitools "Percentage of issues still open")
Expand Down
13 changes: 11 additions & 2 deletions src/app/CliTools/Console/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ abstract class AbstractCommand extends Command {
*/
protected $output;

/**
* Enable automatic terminal title
*
* @var bool
*/
protected $automaticTerminalTitle = true;

/**
* Initializes the command just after the input has been validated.
*
Expand All @@ -65,8 +72,10 @@ protected function initialize(InputInterface $input, OutputInterface $output) {

ConsoleUtility::initialize($input, $output);

// Set default terminal title
$this->setTerminalTitle(explode(':', $this->getName()));
if ($this->automaticTerminalTitle) {
// Set default terminal title
$this->setTerminalTitle(explode(':', $this->getName()));
}
}

/**
Expand Down
20 changes: 15 additions & 5 deletions src/app/CliTools/Console/Command/Mysql/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,37 @@ protected function initialize(InputInterface $input, OutputInterface $output) {
$dsn = null;
$user = null;
$password = null;
$host = DatabaseConnection::getDbHostname();
$port = DatabaseConnection::getDbPort();

// host
if ($this->input->hasOption('host') && $this->input->getOption('host')) {
$host = $this->input->getOption('host');
$port = 3306;
$dsn = false;
}

if ($this->input->getOption('port')) {
$port = $this->input->getOption('port');
}
// port
if ($this->input->hasOption('port') && $this->input->getOption('port')) {
$port = $this->input->getOption('port');
$dsn = false;
}

// rebuild dsn
if ($dsn === false) {
$dsn = 'mysql:host=' . urlencode($host) . ';port=' . (int)$port;
}

// user
if ($this->input->hasOption('user') && $this->input->getOption('user')) {
$user = $this->input->getOption('user');
}

// password
if ($this->input->hasOption('password') && $this->input->getOption('password')) {
$password = $this->input->getOption('password');
}

if ($user !== null || $password !== null) {
if ($dsn !== null || $user !== null || $password !== null) {
DatabaseConnection::setDsn($dsn, $user, $password);
}
}
Expand Down
83 changes: 66 additions & 17 deletions src/app/CliTools/Console/Command/Php/ComposerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,81 @@ protected function configure() {
* @return int|null|void
*/
public function execute(InputInterface $input, OutputInterface $output) {
$composerCmd = $this->getApplication()->getConfigValue('bin', 'composer');

$paramList = $this->getFullParameterList();
$composerJsonPath = UnixUtility::findFileInDirectortyTree('composer.json');

if (!empty($composerJsonPath)) {
$path = dirname($composerJsonPath);
$this->output->writeln('<comment>Found composer.json directory: ' . $path . '</comment>');
if ($this->checkIfComposerJsonIsNeeded($paramList)) {
$composerJsonPath = UnixUtility::findFileInDirectortyTree('composer.json');

// Switch to directory of docker-compose.yml
PhpUtility::chdir($path);
if (!empty($composerJsonPath)) {
$path = dirname($composerJsonPath);
$this->output->writeln('<comment>Found composer.json directory: ' . $path . '</comment>');
// Switch to directory of docker-compose.yml
PhpUtility::chdir($path);

return $this->runComposer($paramList);
} else {
$this->output->writeln('<error>No composer.json found in tree</error>');
return 1;
}
} else {
return $this->runComposer($paramList);
}
}

$command = new CommandBuilder();
$command->parse($composerCmd);
/**
* Check if composer.json is needed for command
*
* @param array $paramList Parameter list for composer
*
* @return int|null|void
*/
protected function checkIfComposerJsonIsNeeded(array $paramList) {
if (empty($paramList)) {
// no params -> show help
return false;
}

if (!empty($paramList)) {
$command->setArgumentList($paramList);
$commandList = array(
'archive',
'dump-autoload',
'dumpautoload',
'info',
'install',
'remove',
'require',
'run-script',
'status',
'suggests',
'update',
'validate',
);

foreach ($commandList as $command) {
if (in_array($command, $paramList, true)) {
return true;
}
}

$command->executeInteractive();
} else {
$this->output->writeln('<error>No composer.json found in tree</error>');
return false;
}

/**
* Run composer command
*
* @param array $paramList Parameter list for composer
*
* @return int|null|void
*/
protected function runComposer(array $paramList) {
$composerCmd = $this->getApplication()->getConfigValue('bin', 'composer');

$command = new CommandBuilder();
$command->parse($composerCmd);

return 1;
if (!empty($paramList)) {
$command->setArgumentList($paramList);
}

return 0;
$command->executeInteractive();
}
}
7 changes: 7 additions & 0 deletions src/app/CliTools/Console/Command/System/BannerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

class BannerCommand extends \CliTools\Console\Command\AbstractCommand implements \CliTools\Console\Filter\OnlyRootFilterInterface {

/**
* Enable automatic terminal title
*
* @var bool
*/
protected $automaticTerminalTitle = false;

/**
* Configure command
*/
Expand Down
2 changes: 1 addition & 1 deletion src/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

error_reporting(E_ALL);
define('CLITOOLS_COMMAND_VERSION', '2.1.0');
define('CLITOOLS_COMMAND_VERSION', '2.1.1');
define('CLITOOLS_ROOT_FS', __DIR__);

require __DIR__ . '/vendor/autoload.php';
Expand Down
20 changes: 10 additions & 10 deletions src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 64761a4

Please sign in to comment.