import { defineCommand, arg } from "politty";
import { z } from "zod";
import { executeCommand } from "../../lib/command-result";
import { runDocModule } from "./module";

export const moduleCommand = defineCommand({
  name: "module",
  description: "Show documentation for a specific module",
  args: z.object({
    name: arg(z.string(), {
      positional: true,
      description: "Module name",
    }),
    type: arg(z.string().optional(), {
      positional: true,
      description: "Doc type (command, query, model, feature)",
    }),
    docName: arg(z.string().optional(), {
      positional: true,
      description: "Doc name",
    }),
    format: arg(z.enum(["text", "json"]).default("text"), {
      alias: "f",
      description: "Output format (text or json)",
    }),
  }),
  run: (args) => {
    return executeCommand(() => runDocModule(args.name, args.type, args.docName, args.format));
  },
});
