# Command line

> The konto command: check a bill to the cent, render it as PDF, XRechnung or HTML, and explain what changed between two bills.

`konto` checks, renders and compares bills on your machine, without a server. An auditor,
a consumer advice centre or a customer can verify a bill offline; a script or CI job can
rely on its exit code.

```sh
cargo install konto          # or from a checkout: cargo install --path crates/konto
konto --help
```

## Commands

| Command | Does |
|---|---|
| `konto check <bill>` | recomputes the bill from its own inputs: „Stimmt auf den Cent.“ or the first difference |
| `konto render <bill> [-f pdf\|cii\|ubl\|html] [-o file]` | writes the PDF (with the e-invoice embedded), the e-invoice in CII or UBL, or the HTML bill |
| `konto diff <older> <newer>` | „Was hat sich geändert?“ between two bills of the same account |
| `konto example [--transfer]` | prints a sealed household bill to try the others on; `--transfer` drops the mandate, so the PDF carries a GiroCode |

`<bill>` is a file or `-` for stdin. It may be the bill itself or kontod's answer to
`GET /v1/bills/{number}`, so this works:

```sh
curl -s -H "Authorization: Bearer $TOKEN" localhost:8080/v1/bills/R-2027-000001 | konto check -
```

`--json` on `check` and `diff` prints the verdict or the full variance as JSON. A PDF is
never written to a terminal; redirect it or use `--output`.

## Exit codes

| Code | Means |
|---|---|
| 0 | the bill holds, or the command succeeded |
| 1 | `check`: the bill differs from its recomputation |
| 2 | the input cannot be read, is not a konto bill, or the command cannot run (the reason is on stderr) |

## Example

```text
$ konto example > rechnung.json
$ konto check rechnung.json
Stimmt auf den Cent.
$ konto render rechnung.json -o rechnung.pdf
$ konto render rechnung.json -f ubl | head -n 2
<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" …>
```
