CLI

Add cli under targets to generate a command-line interface for your API.

{
  "targets": {
    "cli": {
      "binaryName": "acme",
      "defaultFormat": "json",
      "defaultErrorFormat": "json",
      "destinations": {
        "production": {
          "repo": "acme/acme-cli"
        }
      },
      "publish": {
        "homebrew": {
          "tapRepo": "acme/homebrew-tap",
          "homepage": "https://acme.com",
          "description": "Acme API command-line tools"
        }
      }
    }
  }
}

Target Options

Property Type Description
binaryName string Name of the generated command-line binary.
defaultFormat string Default output format for generated commands.
defaultErrorFormat string Default error output format for generated commands.
shellCompletions boolean Ship shell completion scripts and the completion subcommand that prints them. Defaults to true.
skip boolean Set to true to keep the config without generating this target.
destinations object GitHub destinations for generated output.
publish object npm, standalone binary, and Homebrew publishing configuration.

Destinations

Use destinations.production to push generated output to a GitHub repository. This option is available on every target, not just cli.

{
  "targets": {
    "cli": {
      "destinations": {
        "production": {
          "repo": "acme/acme-cli",
          "branch": "main"
        }
      }
    }
  }
}
Property Description
repo GitHub repository in owner/name form.
branch Default branch of the destination repository that releases are promoted to. Defaults to main. Generated output itself always goes to the fixed scalar-generated branch.

Method Commands

Use method-level cli settings in resources to enable, disable, or tune command generation for a specific method.

{
  "resources": {
    "users": {
      "methods": {
        "list": {
          "kind": "http",
          "endpoint": "get /users",
          "verb": "get",
          "path": "/users",
          "defaultRequestOptions": {
            "headers": {}
          },
          "cli": {
            "enabled": true,
            "format": "table"
          }
        }
      }
    }
  }
}
Property Description
enabled Enables or disables CLI command generation for a method.
filter CLI-specific parameter filter expression.
format Default CLI output format for this method.

Publishing

The CLI target supports publish.npm, publish.binaries, and publish.homebrew. The CLI is a Node package, so npm (installed globally with npm install -g) is the primary channel; binaries attaches cross-compiled standalone executables to the GitHub Release, and Homebrew ships a tap formula that installs them. The three are independent and can be combined. See CLI publishing for registry setup.

binaries replaces the older macos key; configs that still set macos are migrated automatically.

{
  "targets": {
    "cli": {
      "publish": {
        "npm": {
          "authMethod": "oidc"
        },
        "binaries": {
          "releaseEnvironment": "production"
        },
        "homebrew": {
          "tapRepo": "acme/homebrew-tap"
        }
      }
    }
  }
}
Property Description
authMethod Registry authentication mechanism, such as oidc or access-token.
releaseEnvironment Release environment name used by generated publishing workflows.
tapRepo Homebrew tap repository for CLI publishing.
homepage Package homepage metadata.
description Package description metadata.