Publier Globinours 1.0.0-rc.3
This commit is contained in:
parent
ea8c24d622
commit
9a2b4068da
325 changed files with 38230 additions and 20 deletions
38
scripts/asm3-movements.php
Normal file
38
scripts/asm3-movements.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
$root = dirname(__DIR__);
|
||||
foreach (['DB', 'Migrations', 'BackupService', 'AppSettings', 'Asm3Analyzer', 'Asm3MovementImporter'] as $service) {
|
||||
require $root . '/app/Services/' . $service . '.php';
|
||||
}
|
||||
$source = null;
|
||||
$apply = false;
|
||||
foreach (array_slice($argv, 1) as $arg) {
|
||||
if ($arg === '--apply') {
|
||||
$apply = true;
|
||||
} elseif (str_starts_with($arg, '--')) {
|
||||
fwrite(STDERR, "Option inconnue : {$arg}\n");
|
||||
exit(2);
|
||||
} else {
|
||||
$source = $arg;
|
||||
}
|
||||
}
|
||||
if (!$source) {
|
||||
fwrite(STDERR, "Usage : php scripts/asm3-movements.php <dump.sql> [--apply]\n");
|
||||
exit(2);
|
||||
}
|
||||
if ($apply) {
|
||||
fwrite(STDERR, 'IMPORT MOUVEMENTS demandé. Tapez IMPORTER MOUVEMENTS : ');
|
||||
if (trim((string) fgets(STDIN)) !== 'IMPORTER MOUVEMENTS') {
|
||||
fwrite(STDERR, "Import annulé.\n");
|
||||
exit(3);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Migrations::run($root . '/migrations');
|
||||
echo json_encode(Asm3MovementImporter::run($source, DB::pdo(), $apply), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE),
|
||||
"\n";
|
||||
} catch (Throwable $e) {
|
||||
fwrite(STDERR, "Échec : {$e->getMessage()}\n");
|
||||
exit(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue