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

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