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

export const thinCommand = defineCommand({
  name: "thin",
  description: "Measure implementation thinness across resolvers, commands, and frontend pages",
  args: z.object({
    appRoot: arg(z.string().optional(), {
      alias: "a",
      description: "Path to an app directory (measures resolvers + frontend)",
    }),
    modulesRoot: arg(z.string().optional(), {
      alias: "m",
      description: "Path to a modules directory (measures commands + lib)",
    }),
  }),
  run: (args) => {
    return executeCommand(() =>
      runInternalMeasureThin(
        { appRoot: args.appRoot, modulesRoot: args.modulesRoot },
        process.cwd(),
      ),
    );
  },
});
