> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiIyMzM2ODg0ZC01MjcxLTQ5YmQtOWJhMi04MGJjOTQwMmM5YWQiLCJleHAiOjE3NzkxNTU0NjQsImlhdCI6MTc3OTE1NTE2NH0.bOs_AfCcnloYqPxHIBqqppTEcJMo1U40pAEcX0mLiWQ
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# Features

> Explore the capabilities of Fern's generated CLIs, including output formatting, pagination, dry-run mode, and TLS configuration.

The CLI generator is in early access. [Reach out](https://buildwithfern.com/book-demo?type=cli) to get started.

Generated CLIs ship with a common set of runtime flags and environment variables: output formatting, pagination, dry-run previewing, TLS and proxy configuration, exit codes, and structured logging. APIs with templated server URLs also expose per-variable flags and environment variables.

## Output formatting

Use the `--format` flag to control how responses are displayed.

| Format | Flag             | Description                                                            |
| ------ | ---------------- | ---------------------------------------------------------------------- |
| JSON   | `--format json`  | Default. Pretty-printed JSON.                                          |
| Table  | `--format table` | Columnar table. Nested objects flatten to `parent.child` column names. |
| YAML   | `--format yaml`  | YAML representation of the response.                                   |
| CSV    | `--format csv`   | Comma-separated values, suitable for piping into spreadsheet tools.    |

```bash
# Display plants in a table
contoso plants list --format table

# Export orders as CSV
contoso orders list --format csv > orders.csv
```

## Dry-run mode

Pass `--dry-run` to validate arguments and preview the HTTP request without sending it. The CLI prints the method, URL, headers, and body it would send, then exits.

```bash
contoso plants get --params '{"plantId": "abc"}' --dry-run
```

## Pagination

For endpoints annotated with [`x-fern-pagination`](/learn/api-definitions/openapi/extensions/pagination), the CLI auto-paginates when the `--page-all` flag is set.

| Flag                | Description                                                | Default |
| ------------------- | ---------------------------------------------------------- | ------- |
| `--page-all`        | Fetch every page and emit one JSON line per page (NDJSON). | Off     |
| `--page-limit <N>`  | Maximum number of pages to fetch.                          | 10      |
| `--page-delay <MS>` | Delay in milliseconds between page requests.               | 100     |

```bash
# Fetch all plants, one JSON line per page
contoso plants list --page-all

# Limit to 5 pages with a 200 ms delay
contoso plants list --page-all --page-limit 5 --page-delay 200
```

Paginated output works with all output formats. For table and CSV formats, headers are only emitted on the first page so the output concatenates cleanly.

## Passing parameters

| Flag              | Purpose                                         |
| ----------------- | ----------------------------------------------- |
| `--params <JSON>` | URL path and query parameters as a JSON object. |
| `--json <JSON>`   | Request body for POST, PUT, and PATCH methods.  |

```bash
# Path + query parameters
contoso plants get --params '{"plantId": "abc"}'

# Request body
contoso plants create \
  --json '{"name": "Monstera", "species": "Monstera deliciosa", "sunlight": "indirect"}'
```

## Server URL variables

For APIs with [templated server URLs](/learn/api-definitions/openapi/extensions/server-names-and-url-templating) (such as `https://api.example.com/stores/{store_hash}/v3`), the CLI automatically exposes each template variable as a CLI flag and environment variable.

```bash
# Pass the variable as a flag
bigcommerce --store-hash abc123 v3 customers list

# Or set it via an environment variable
export BIGCOMMERCE_STORE_HASH=abc123
bigcommerce v3 customers list
```

## File uploads and downloads

For endpoints with `format: binary` request bodies, pass a file path as the `--file` argument. For binary responses, use `--output <PATH>` to save the response body to a file.

## Exit codes

| Code | Meaning          | Example cause                                    |
| ---- | ---------------- | ------------------------------------------------ |
| `0`  | Success          | Command completed normally.                      |
| `1`  | API error        | Server returned a 4xx/5xx response.              |
| `2`  | Auth error       | Credentials missing or invalid.                  |
| `3`  | Validation error | Bad arguments, unknown command, or invalid JSON. |
| `4`  | Discovery error  | Couldn't load API schema.                        |
| `5`  | Internal error   | Unexpected failure.                              |

All errors are emitted as structured JSON on stderr, making them easy to parse in scripts and CI pipelines.

## TLS, proxies, and CA bundles

Every generated CLI honors environment variables for TLS and proxy configuration at runtime. Variables are scoped by binary name — `<NAME>` is the CLI's binary name uppercased with hyphens mapped to underscores (for example, `CONTOSO`).

| Variable                      | Effect                                                            |
| ----------------------------- | ----------------------------------------------------------------- |
| `<NAME>_CA_BUNDLE`            | Path to a PEM file appended to the default trust roots.           |
| `<NAME>_INSECURE=1`           | Disable TLS verification. Logs a warning. Not for production use. |
| `<NAME>_PROXY`                | HTTP/HTTPS proxy URL, overriding `HTTPS_PROXY` / `HTTP_PROXY`.    |
| `<NAME>_NO_PROXY`             | Comma-separated proxy bypass list scoped to this CLI.             |
| `<NAME>_TIMEOUT_SECS`         | Total request timeout. None by default.                           |
| `<NAME>_CONNECT_TIMEOUT_SECS` | Connection-establishment timeout.                                 |

Standard environment variables (`HTTPS_PROXY`, `HTTP_PROXY`, `NO_PROXY`, `SSL_CERT_FILE`) are honored when the scoped overrides are absent.

**Behind a MITM proxy (Proxyman, Charles, mitmproxy):**

```bash
export SSL_CERT_FILE=~/path/to/proxyman-ca.pem
export HTTPS_PROXY=http://127.0.0.1:9090
contoso plants list
```

**Corporate network with a custom root CA:**

```bash
export CONTOSO_CA_BUNDLE=/etc/ssl/corp-roots.pem
contoso plants list
```

## Structured logging

Logging is off by default. Set `<NAME>_LOG` to a [tracing filter](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html) to emit structured logs to stderr. Set `<NAME>_LOG_FILE` to a directory path to write daily rotated JSON log files.

```bash
CONTOSO_LOG=debug contoso plants list
```