import { defineCommand, arg } from "politty";
import { z } from "zod";
import { runCheck } from "../../lib/check";
import { executeCommand } from "../../lib/command-result";
import { buildModuleCheckTargets } from "./targets";

export const checkCommand = defineCommand({
  name: "check",
  description: "Validate module docs against schemas",
  args: z.object({
    path: arg(z.string(), {
      alias: "p",
      description: "Path to modules directory",
    }),
  }),
  run: (args) => {
    return executeCommand(() => runCheck(buildModuleCheckTargets(args.path), process.cwd()));
  },
});
