# Command-line printing (Windows)

Print a `.pos` template without opening the GUI.

Run `posprint cli-help` to print this section from the binary (no GUI required).

## Syntax

```powershell
posprint print <file.pos> --printer <PORT> --set Name=Value [--set Other=Value ...]
```

Short form:

```powershell
posprint print receipt.pos -p COM3 --set StoreName="My Shop" --set DocumentNumber=1001
```

## Rules

- **`--printer` / `-p`** (required): USB-serial port name, e.g. `COM3`, `COM4`.
- **`--set NAME=VALUE`** (required for every parameter): one flag per `${Name}` in the template.
- If any `${Name}` is missing or empty, the command **fails** and lists missing parameters.
- The GUI is not started when using the `print` subcommand.

## Examples

List required parameters by opening the template in the designer, or inspect the `${...}` tokens in the file body.

```powershell
posprint print C:\receipts\sale.pos -p COM3 `
  --set StoreName="Corner Cafe" `
  --set DocumentNumber=42 `
  --set Date=2026-07-15 `
  --set GrandTotal=19.99
```

## Printer port

- Open **Device Manager → Ports (COM & LPT)** to find the printer COM port.
- Install the USB-serial driver if the device is not listed.
- Close other programs using the same COM port before printing.

## Exit codes

| Code | Meaning |
|------|---------|
| `0` | Printed successfully |
| `1` | Error (missing parameters, parse error, port error, etc.) |

## Help

```powershell
posprint print --help
posprint --help
```

Launch the graphical designer by running `posprint` with **no** subcommand.
