#!/usr/bin/env node
import { runResetAdminPassword } from "./core/cli/reset-admin-password.js";
import { runSetupWizard } from "./core/setup/wizard.js";
import { privateFamilyProvider } from "./modules/privatefamily/family-provider.js";
const COMMANDS = ["setup", "reset-admin-password", "version"];
function usage() {
    console.log(`
private-server — serveur familial autonome (SQLite, mono-utilisateur)

Usage :
  private-server <commande> [options]

Commandes :
  setup                  Assistant de premier lancement : domaine (et
                         instructions DNS + Caddyfile), compte admin, nom de
                         la famille. Affichage final de l'URL + identifiants.
                         Options : --domain <d> --email <e> --password <p>
                                   --family <nom> --yes --no-caddy
  reset-admin-password   Réinitialise le mot de passe d'un compte (mode oublié)
                         et révoque tous ses refresh tokens.
                         Options : --email <email> --password <motdepasse>
                         Sans options : saisie interactive.
  version                Affiche la version.
`);
}
const args = process.argv.slice(2);
const command = (args[0] ?? "");
switch (command) {
    case "setup":
        runSetupWizard(args.slice(1), { familyProvider: privateFamilyProvider })
            .then(() => process.exit(0))
            .catch((err) => {
            console.error(`Erreur : ${err.message}`);
            process.exit(1);
        });
        break;
        runResetAdminPassword(args.slice(1))
            .then(() => process.exit(0))
            .catch((err) => {
            console.error(`Erreur : ${err.message}`);
            process.exit(1);
        });
        break;
    case "version": {
        const pkg = JSON.parse(await import("node:fs/promises").then((fs) => fs.readFile(new URL("../package.json", import.meta.url), "utf8")));
        console.log(pkg.version);
        break;
    }
    case "--help":
    case "-h":
    case "":
        usage();
        break;
    default:
        console.error(`Commande inconnue : "${command}"`);
        usage();
        process.exit(1);
}
//# sourceMappingURL=cli.js.map