#!/usr/bin/env php
<?php

require __DIR__ . '/../vendor/autoload.php';

use Jane\JsonSchema\Console\Command\GenerateCommand;
use Jane\JsonSchema\Console\Loader\ConfigLoader;
use Jane\JsonSchema\Console\Loader\SchemaLoader;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;

$command = new GenerateCommand(new ConfigLoader(), new SchemaLoader());
$inputArray = new ArrayInput(['--config-file' => __DIR__ . '/../config/jane/json_schema.php'], $command->getDefinition());
$output = new ConsoleOutput();

try {
    exit($command->execute($inputArray, $output));
} catch (\Throwable $throwable) {
    (new Application())->renderThrowable($throwable, $output->getErrorOutput());

    exit(1);
}
