| 
<?phpdeclare(strict_types=1);
 namespace ParagonIE\Chronicle\CliTests;
 
 use GuzzleHttp\Client;
 use ParagonIE\Chronicle\Chronicle;
 use ParagonIE\EasyDB\EasyDB;
 use ParagonIE\EasyDB\Factory;
 use ParagonIE\Sapient\Adapter\Guzzle;
 use ParagonIE\Sapient\Sapient;
 use GetOpt\{
 GetOpt,
 Option
 };
 
 require_once dirname(dirname(__DIR__)) . '/cli-autoload.php';
 
 
 if (!\is_readable(CHRONICLE_APP_ROOT . '/local/settings.json')) {
 echo 'Settings are not loaded.', PHP_EOL;
 exit(1);
 }
 
 $settings = \json_decode(
 (string) \file_get_contents(CHRONICLE_APP_ROOT . '/local/settings.json'),
 true
 );
 
 /** @var EasyDB $db */
 $db = Factory::create(
 $settings['database']['dsn'],
 $settings['database']['username'] ?? '',
 $settings['database']['password'] ?? '',
 $settings['database']['options'] ?? []
 );
 Chronicle::setDatabase($db);
 
 /**
 * @var GetOpt
 *
 * This defines the Command Line options.
 */
 $getopt = new GetOpt([
 new Option(null, 'base-url', GetOpt::REQUIRED_ARGUMENT)
 ]);
 $getopt->process();
 $baseUrl = $getopt->getOption('base-url') ?? 'http://localhost:8080';
 
 $http = new Client();
 $sapient = new Sapient(new Guzzle($http));
 $serverPublicKey = Chronicle::getSigningKey()->getPublickey();
 
 |