#!/usr/bin/env node
// @ts-nocheck
import { runCatalogMaker } from "./workflows/catalog-maker.ts";
import { loadConfig } from "./config.ts";
import { parseArgs } from "./lib/args.ts";
import { fail } from "./lib/log.ts";

const args = parseArgs(process.argv.slice(2));
const command = args._[0] ?? "catalog-maker";

try {
  const config = loadConfig({
    configPath: args.config ?? "config/local.json",
    dryRun: args["dry-run"] ?? undefined,
  });

  if (command === "catalog-maker") {
    await runCatalogMaker({ config });
  } else {
    throw new Error(`Unknown command: ${command}`);
  }
} catch (error) {
  fail(error);
  process.exitCode = 1;
}
