Merge remote-tracking branch 'digitalkaoz/validate_command'
commit
a193ec9942
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Command;
|
||||||
|
|
||||||
|
use Composer\Repository\PlatformRepository;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Composer\Json\JsonFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Robert Schönthal <seroscho@googlemail.com>
|
||||||
|
*/
|
||||||
|
class ValidateCommand extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('validate')
|
||||||
|
->setDescription('validates a composer.json')
|
||||||
|
->setDefinition(array(
|
||||||
|
new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file', getcwd().'/composer.json')
|
||||||
|
))
|
||||||
|
->setHelp(<<<EOT
|
||||||
|
The validate command validates a given composer.json
|
||||||
|
<info>php composer.phar validate</info> for current location
|
||||||
|
or
|
||||||
|
<info>php composer.phar validate /path/to/composer.json</info> for custom location
|
||||||
|
|
||||||
|
EOT
|
||||||
|
)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$file = $input->getArgument('file');
|
||||||
|
|
||||||
|
if (!is_readable($file)) {
|
||||||
|
throw new \InvalidArgumentException('composer.json not found '.$file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = JsonFile::parseJson(file_get_contents($file));
|
||||||
|
$output->writeln('<info>valid</info> '.$file.' is valid');
|
||||||
|
}
|
||||||
|
}
|
|
@ -175,6 +175,7 @@ class Application extends BaseApplication
|
||||||
$this->add(new Command\UpdateCommand());
|
$this->add(new Command\UpdateCommand());
|
||||||
$this->add(new Command\DebugPackagesCommand());
|
$this->add(new Command\DebugPackagesCommand());
|
||||||
$this->add(new Command\SearchCommand());
|
$this->add(new Command\SearchCommand());
|
||||||
|
$this->add(new Command\ValidateCommand());
|
||||||
|
|
||||||
if ('phar:' === substr(__FILE__, 0, 5)) {
|
if ('phar:' === substr(__FILE__, 0, 5)) {
|
||||||
$this->add(new Command\SelfUpdateCommand());
|
$this->add(new Command\SelfUpdateCommand());
|
||||||
|
|
Loading…
Reference in New Issue