get('DB')); $username = trim((string) ($argv[1] ?? '')); if ($username === '') { fwrite(STDERR, "Usage: php scripts/create-admin.php \n"); exit(1); } fwrite(STDOUT, 'Mot de passe (10 caractères minimum): '); if (stripos(PHP_OS, 'WIN') !== 0) { system('stty -echo'); } $password = trim((string) fgets(STDIN)); if (stripos(PHP_OS, 'WIN') !== 0) { system('stty echo'); } fwrite(STDOUT, PHP_EOL); try { $id = (new User())->create($username, $password); fwrite(STDOUT, "Admin créé (ID {$id}).\n"); } catch (RuntimeException $e) { fwrite(STDERR, $e->getMessage() . PHP_EOL); exit(1); }