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

export const startCommand = defineCommand({
  name: "start",
  description: "Start mock API servers with reverse proxy",
  args: z.object({
    mocksRoot: arg(z.string().default("./mocks"), {
      description: "Path to mocks directory",
    }),
    port: arg(z.coerce.number().default(3000), {
      alias: "p",
      description: "Reverse proxy port",
    }),
    filter: arg(z.array(z.string()).default([]), {
      positional: true,
      description: "Filter by provider or provider/scenario",
    }),
  }),
  run: (args) => {
    return executeCommand(() => runMockStart(args.mocksRoot, args.filter, args.port));
  },
});
