Globinours/scripts/asm3-litters.php

20 lines
637 B
PHP

#!/usr/bin/env php
<?php
declare(strict_types=1);
$root = dirname(__DIR__);
foreach (['DB', 'Migrations', 'BackupService', 'AppSettings', 'Asm3Analyzer', 'Asm3LitterImporter'] as $s) {
require $root . '/app/Services/' . $s . '.php';
}
$p = $argv[1] ?? null;
$apply = in_array('--apply', $argv, true);
if (!$p) {
exit(2);
}
if ($apply) {
fwrite(STDERR, 'Tapez IMPORTER PORTEES : ');
if (trim((string) fgets(STDIN)) !== 'IMPORTER PORTEES') {
exit(3);
}
}
Migrations::run($root . '/migrations');
echo json_encode(Asm3LitterImporter::run($p, DB::pdo(), $apply), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), "\n";