* Jordi Boggiano * * 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 */ 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(<<php composer.phar validate for current location or php composer.phar validate /path/to/composer.json 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('valid '.$file.' is valid'); } }