# CLI — `mdwire`

> The mdwire command — flags, output format, the repair report and batch mode.

HTML: https://mdwire.minjun.dev/docs/cli/

Reads Markdown on stdin, writes the channel's output on stdout. Any agent in any language can pipe
through it with no bindings.

```sh
cargo install mdwire-cli                                   # Rust
go install github.com/minjun0219/mdwire/go/cmd/mdwire@latest  # Go — same flags, no -V/--version
```

Every [release](https://github.com/minjun0219/mdwire/releases) also carries a binary for macOS
(Apple silicon) and Linux (x86_64), with a SHA-256 for each in the notes.

```sh
cat agent-output.md | mdwire --channel telegram-html            # parts separated by NUL
cat agent-output.md | mdwire --channel slack-markdown --stream  # emit as it arrives
cat agent-output.md | mdwire --channel plain --limit 4096       # plain fallback into Telegram
cat agent-output.md | mdwire --channel slack-markdown --from slack-mrkdwn --report
```

## Flags

| Flag | |
|---|---|
| `--channel <name>` | Required. `telegram-html` · `slack-markdown` · `github-markdown` · `notion-markdown` · `plain` · `html` |
| `--from <dialect>` | Input dialect: `markdown` (default) · `slack-mrkdwn` |
| `--limit <chars>` | Part limit. Defaults to the channel's. |
| `--html-line-breaks <br\|space>` | `html` only. Default `br`. |
| `--html-images <link\|load>` | `html` only. Default `link`. |
| `--html-schemes <list>` | `html` only. Comma-separated; default `http,https,mailto`. |
| `--stream` | Emit as stdin is read. Does not split by the limit. |
| `--report` | Print the repair report on stderr as one JSON line. |
| `--batch jsonl` | Read many documents as JSON lines; print one report per document. |
| `-h`, `--help` · `-V`, `--version` | Help · version (Rust CLI). |

A flag that takes a value also takes `--name=value` (`--channel=slack-markdown`).

Channels, dialects and options are explained on [Concepts](https://mdwire.minjun.dev/docs/).

## Output

- Batch (the default): the parts, separated by NUL (`\0`) when there is more than one.
- `--stream`: one continuous stream — the pieces concatenated, which equals the batch output unless
  the batch output was split.

## `--report`

One JSON line on stderr:

```json
{"closedEmphasis":1,"closedFence":0,"revertedCodeSpan":0,"droppedMarker":0,"escapedChar":0,"tagEmphasis":0,"strippedHtml":0,"rewrittenBullet":0,"rewrittenTable":0,"convertedMarker":0}
```

The first four keys are repairs; the other six are channel rewrites. What each counts:
[the repair report](https://mdwire.minjun.dev/docs/#the-repair-report).

## `--batch jsonl`

Many documents through one process — for checking how often hundreds of answers break. Prints the
report per document, not the rendered output.

```text
in   {"id": "a1", "text": "**markdown"}         id is a string or a number, and optional
out  {"line":1,"id":"a1","closedEmphasis":1,…}
bad  {"line":2,"error":"…"}                     reading continues; any bad line makes the exit code non-zero
```
