Skip to content

Commit

Permalink
Merge branch 'release/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mblaschke committed Jul 22, 2015
2 parents 64761a4 + 633c075 commit 80e0e00
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CliTools Changelog
==================

2.1.2 - 2015-07-22
------------------
- Fixed smaller issues
- Rollback to Symfony 2.7.1

2.1.1 - 2015-07-17
------------------
- Fixed `php:composer` global command usage
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ install:

autoload:
sh -c "cd src ; composer dump-autoload --optimize --no-dev"

sloccount:
sloccount src/app/ src/command.php
125 changes: 125 additions & 0 deletions src/app/CliTools/Console/Command/Common/FixRightsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php

namespace CliTools\Console\Command\Common;

/*
* CliTools Command
* Copyright (C) 2015 Markus Blaschke <markus@familie-blaschke.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

class FixRightsCommand extends \CliTools\Console\Command\AbstractCommand {

/**
* Configure command
*/
protected function configure() {
$this
->setName('fix-rights')
->setDescription('Fix rights of multiple directories and files')
->addArgument(
'path',
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
'Path (multiple)'
);
}

/**
* Execute command
*
* @param InputInterface $input Input instance
* @param OutputInterface $output Output instance
*
* @return int|null|void
*/
public function execute(InputInterface $input, OutputInterface $output) {
$pathList = $this->input->getArgument('path');

$this->checkPathList($pathList);


foreach ($pathList as $path) {
if (is_dir($path)) {
$iterator = new \RecursiveDirectoryIterator($path);
$iterator = new \RecursiveIteratorIterator($iterator);

/** @var \SplFileInfo $entry */
foreach ($iterator as $entry) {
$this->setRights($entry);
}
} else {
$entry = new \SplFileInfo($path);
$this->setRights($entry);
}
}
}

/**
* Set rights for file
*
* @param \SplFileInfo $file
*/
protected function setRights(\SplFileInfo $file) {
$isDir = false;

if ($file->isDir()) {
$perms = fileperms($file->getPathname());
$isDir = true;
} elseif ($file->isFile()) {
$perms = fileperms($file->getPathname());
}

// Owner
$perms = $perms | 0x0100;
$perms = $perms | 0x0080;
if ($isDir) {
$perms = $perms | 0x0800;
}

// Group
$perms = $perms | 0x0020;
$perms = $perms | 0x0010;
if ($isDir) {
$perms = $perms | 0x0800;
}

// Others
$perms = $perms | 0x0004;
$perms = $perms | 0x0002;
if ($isDir) {
$perms = $perms | 0x0800;
}

chmod($file->getPathname(), $perms);
}

/**
* Check path list
*
* @param $pathList
* @throws \RuntimeException
*/
protected function checkPathList($pathList) {
foreach ($pathList as $path) {
if (!file_exists($path)) {
throw new \RuntimeException('Path "' . $path . '" does not exists or is not writeable');
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use CliTools\Console\Shell\Executor;
use CliTools\Shell\Executor;

class AbstractCommandBuilder implements CommandBuilderInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use CliTools\Console\Shell\Executor;
use CliTools\Shell\Executor;

interface CommandBuilderInterface {
/**
Expand Down Expand Up @@ -245,28 +245,28 @@ public function build();
/**
* Get executor
*
* @return \CliTools\Console\Shell\Executor
* @return \CliTools\Shell\Executor
*/
public function getExecutor();

/**
* Set executor
*
* @param \CliTools\Console\Shell\Executor $executor
* @param \CliTools\Shell\Executor $executor
*/
public function setExecutor(\CliTools\Console\Shell\Executor $executor);
public function setExecutor(\CliTools\Shell\Executor $executor);

/**
* Execute command
*
* @return \CliTools\Console\Shell\Executor
* @return \CliTools\Shell\Executor
*/
public function execute();

/**
* Execute command
*
* @return \CliTools\Console\Shell\Executor
* @return \CliTools\Shell\Executor
*/
public function executeInteractive();

Expand Down
2 changes: 1 addition & 1 deletion src/app/CliTools/Shell/Executor.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace CliTools\Console\Shell;
namespace CliTools\Shell;

/*
* CliTools Command
Expand Down
2 changes: 1 addition & 1 deletion src/app/CliTools/Utility/DockerUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

use CliTools\Shell\CommandBuilder\CommandBuilder;
use CliTools\Console\Shell\Executor;
use CliTools\Shell\Executor;

class DockerUtility {

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.1');
define('CLITOOLS_COMMAND_VERSION', '2.1.2');
define('CLITOOLS_ROOT_FS', __DIR__);

require __DIR__ . '/vendor/autoload.php';
Expand Down
2 changes: 1 addition & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{ "type": "vcs", "url": "https://github.com/jamiebicknell/Growl-GNTP.git" }
],
"require": {
"symfony/console": "2.*",
"symfony/console": "2.7.1",
"jamiebicknell/Growl-GNTP": "dev-master",
"symfony/yaml": "^2.6"
},
Expand Down
12 changes: 6 additions & 6 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 80e0e00

Please sign in to comment.