import { registerOperationCommand } from '../../../runtime/operation-command'
import type { CliOperationSpec } from '../../../runtime/types'
import type { Command } from 'commander'

const spec = {
  "arguments": [
    {
      "name": "owner",
      "required": true,
      "target": "path.owner",
      "type": "string"
    },
    {
      "name": "repo",
      "required": true,
      "target": "path.repo",
      "type": "string"
    },
    {
      "name": "number",
      "required": true,
      "target": "path.number",
      "type": "string"
    }
  ],
  "command": [
    "pull-request",
    "merge"
  ],
  "description": "Merge a pull request using a repository-allowed merge method",
  "flags": [
    {
      "name": "mergeMethod",
      "required": true,
      "target": "body.mergeMethod",
      "type": "string",
      "values": [
        "merge",
        "squash",
        "rebase"
      ]
    },
    {
      "name": "commitTitle",
      "required": false,
      "target": "body.commitTitle",
      "type": "string"
    },
    {
      "name": "commitMessage",
      "required": false,
      "target": "body.commitMessage",
      "type": "string"
    }
  ],
  "method": "post",
  "path": "/pull-requests/{owner}/{repo}/{number}/merge"
} satisfies CliOperationSpec

export function register(program: Command): void {
  registerOperationCommand(program, spec)
}
