* 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 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 * @author Jordi Boggiano */ 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', './composer.json') )) ->setHelp(<<getArgument('file'); if (!file_exists($file)) { $output->writeln(''.$file.' not found.'); return 1; } if (!is_readable($file)) { $output->writeln(''.$file.' is not readable.'); return 1; } try { JsonFile::parseJson(file_get_contents($file), true); } catch (\Exception $e) { $output->writeln(''.$e->getMessage().''); return 1; } $output->writeln(''.$file.' is valid'); } }