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

export const logCommand = defineCommand({
  name: "log",
  description: "Append a validated entry to the progress log",
  args: z.object({
    json: arg(z.string(), {
      description: "JSON payload (ProgressInput schema)",
    }),
    "dry-run": arg(z.boolean().default(false), {
      description: "Validate without writing",
    }),
  }),
  run: (args) => {
    return executeCommand(() => runAppProgressLog(args.json, args["dry-run"], process.cwd()));
  },
});
