import path from "node:path";
import { defineCommand, arg } from "politty";
import { z } from "zod";
import { executeCommand } from "../../../lib/command-result";
import { runAppGenerateCode } from "./code";

export const codeCommand = defineCommand({
  name: "code",
  description: "Generate boilerplate source files from docs",
  args: z.object({
    path: arg(z.string(), {
      alias: "p",
      description: "Path to app directory",
    }),
  }),
  run: (args) => {
    return executeCommand(() => {
      const appPath = path.resolve(process.cwd(), args.path);
      return runAppGenerateCode(appPath);
    });
  },
});
