import type { ParsedCommandDoc } from "./parse-command-doc";

export function generateCommandShell(doc: ParsedCommandDoc): string {
  const lines: string[] = [
    `// @generated — do not edit`,
    `import { permissions } from "../lib/permissions.generated";`,
    `import { run } from "./${doc.commandName}";`,
    `import { defineCommand } from "@tailor-platform/erp-kit/core";`,
    ``,
    `export const ${doc.commandName} = defineCommand("${doc.commandName}", permissions.${doc.permissionScope}.${doc.commandName}, run);`,
    ``,
  ];

  return lines.join("\n");
}

export function generateQueryShell(doc: ParsedCommandDoc): string {
  const lines: string[] = [
    `// @generated — do not edit`,
    `import { run } from "./${doc.commandName}";`,
    `import { defineQuery } from "@tailor-platform/erp-kit/core";`,
    ``,
    `export const ${doc.commandName} = defineQuery("${doc.commandName}", run);`,
    ``,
  ];

  return lines.join("\n");
}
