import { defineCommand, arg } from "politty";
import { z } from "zod";
import { executeCommand } from "../../../lib/command-result";
import { runModuleGenerateDoc, MODULE_DOC_TYPES } from "./doc";

export const docCommand = defineCommand({
  name: "doc",
  description: "Create a documentation file from a schema template",
  args: z.object({
    path: arg(z.string(), {
      alias: "p",
      description: "Path to the module directory",
    }),
    type: arg(z.enum(MODULE_DOC_TYPES), {
      positional: true,
      description: `Doc type (${MODULE_DOC_TYPES.join(", ")})`,
    }),
    name: arg(z.string().optional(), {
      positional: true,
      description: "Item name (required for all types)",
    }),
  }),
  run: (args) => {
    return executeCommand(() =>
      runModuleGenerateDoc(args.type, args.name, args.path, process.cwd()),
    );
  },
});
