You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
765 B
Plaintext

#!/usr/bin/env php
<?php
use Engelsystem\Controllers\Admin\Schedule\ImportSchedule;
use ErrorException;
use stdClass;
require_once __DIR__ . '/../includes/application.php';
$script = array_shift($argv);
if (count($argv) === 0) {
echo "usage: $script '*'|SCHEDULE_ID [SCHEDULE_ID...]" . PHP_EOL;
exit;
}
$app = app();
$scheduleIds = $argv;
if ($argv[0] === '*') {
$db = $app->get('database');
3 years ago
$scheduleIds = array_map(fn(stdClass $schedule) => $schedule->id, $db->select('SELECT id FROM schedules'));
}
$importer = $app->get(ImportSchedule::class);
foreach ($scheduleIds as $id) {
try {
$importer->doImport($id);
} catch (ErrorException $e) {
echo "import '$id' failed:" . PHP_EOL . $e->getMessage() . PHP_EOL;
}
}