import { define } from './chunk-WAUK6TES.js';
import { checkForSchemaErrors, checkForNoEnvFiles } from './chunk-BD2Y6HCS.js';
import { loadVarlockEnvGraph } from './chunk-7NQY4SIN.js';
import { CliExitError } from './chunk-RZCYQIYU.js';
import { __name } from './chunk-IBAHCH6O.js';

// src/cli/commands/typegen.command.ts
var commandSpec = define({
  name: "typegen",
  description: "Generate TypeScript types from your env schema",
  args: {
    path: {
      type: "string",
      short: "p",
      multiple: true,
      description: "Path to a specific .env file or directory to use as the entry point (can be specified multiple times)"
    }
  },
  examples: `
Generates TypeScript type definitions from your .env schema files.
Uses only your schema definitions, so output is deterministic regardless of
which environment is active. Keys that come only from value files like .env or
.env.local are ignored - only items declared in your schema are included.

This is useful when you have \`@generateTypes(lang=ts, path=env.d.ts, auto=false)\`
in your schema to disable automatic type generation during \`varlock load\` or \`varlock run\`.

Examples:
  varlock typegen                    # Generate types using default schema
  varlock typegen --path .env.prod   # Generate types from a specific .env file
`.trim()
});
var commandFn = /* @__PURE__ */ __name(async (ctx) => {
  const envGraph = await loadVarlockEnvGraph({
    entryFilePaths: ctx.values.path
  });
  checkForSchemaErrors(envGraph);
  checkForNoEnvFiles(envGraph);
  const generatedCount = await envGraph.generateTypesIfNeeded({ ignoreAutoFalse: true });
  if (generatedCount === 0) {
    throw new CliExitError("No @generateTypes decorator found in your schema", {
      suggestion: "Add `@generateTypes(lang=ts, path=env.d.ts)` to your .env.schema file."
    });
  }
  console.log("\u2705 Types generated successfully");
  const excludedKeys = envGraph.getValueOnlyKeysExcludedFromTypes();
  if (excludedKeys.length) {
    console.log("");
    console.log(`\u2139\uFE0F  Ignored ${excludedKeys.length} key${excludedKeys.length === 1 ? "" : "s"} found only in .env (not declared in your schema):`);
    console.log(`   ${excludedKeys.join(", ")}`);
    console.log("   Declare them in your .env.schema to include them in generated types.");
  }
}, "commandFn");

export { commandFn, commandSpec };
//# sourceMappingURL=chunk-PNH4SGQC.js.map
//# sourceMappingURL=chunk-PNH4SGQC.js.map