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

export const structureCommand = defineCommand({
  name: "structure",
  description:
    "Check repository structure: naming/placement against bundled rule tree + required-dir presence",
  args: z.object({
    appRoot: arg(z.string().optional(), {
      alias: "a",
      description: "Path to an app directory (scans resolvers + app shape)",
    }),
    modulesRoot: arg(z.string().optional(), {
      alias: "m",
      description: "Path to a modules directory (checks module structure)",
    }),
  }),
  run: (args) => {
    return executeCommand(() =>
      runInternalMeasureStructure(
        { appRoot: args.appRoot, modulesRoot: args.modulesRoot },
        process.cwd(),
      ),
    );
  },
});
