import { defineCommand, arg } from "politty";
import { z } from "zod";
import { executeCommand } from "../../../lib/command-result";
import { runAppGenerateDoc, APP_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 app directory",
    }),
    type: arg(z.enum(APP_DOC_TYPES), {
      positional: true,
      description: `Doc type (${APP_DOC_TYPES.join(", ")})`,
    }),
    name: arg(z.string().optional(), {
      positional: true,
      description: "Item name (required for most types)",
    }),
  }),
  run: (args) => {
    return executeCommand(() => runAppGenerateDoc(args.type, args.name, args.path, process.cwd()));
  },
});
