CI / test (push) Failing after 6m11s
- receipt_tui.py: Textual terminal UI (tui subcommand), optional [tui] extra - tests/: pytest suite for CLI and TUI using fakes; no hardware needed - pyproject.toml: packaging with dev/tui extras, ruff config - GitHub Actions CI running ruff and pytest - Rename connect_recipt.sh -> connect_receipt.sh - CLAUDE.md project instructions; README updates Co-Authored-By: Claude Fable 5 <[email protected]>
27 lines
1.6 KiB
Markdown
27 lines
1.6 KiB
Markdown
# Receipt Maker
|
|
|
|
CLI that prints images, notes, and QR codes to an Epson TM-T20II thermal receipt printer (Ethernet via USB adapter, or direct USB with `--usb`).
|
|
|
|
## Layout
|
|
|
|
- `receipt.py` — the CLI; subcommand per `cmd_*` function
|
|
- `receipt_tui.py` — Textual TUI (`tui` subcommand); thin layer over the `cmd_*` handlers via `run_action()`, which connects fresh per action and captures stdout/stderr for the log panel. `textual` is an optional dependency (`[tui]` extra); the CLI works without it
|
|
- `connect_receipt.sh` — brings up the printer's network interface (needs sudo); run automatically before any print over Ethernet. The TUI runs it with output captured (`setup_network_quiet`) so it can't corrupt the screen
|
|
- `tests/` — pytest suite; uses `FakePrinter` + mocked `requests`, never touches hardware or network
|
|
|
|
## Conventions
|
|
|
|
- Printer/network constants live at the top of `receipt.py`; IP/port overridable via `--ip`/`--port` or `RECEIPT_PRINTER_IP`/`RECEIPT_PRINTER_PORT`
|
|
- Images are prepared in memory (`prepare_for_print`: white-composite alpha → resize to 576px → autocontrast → 1-bit dither); nothing is written except the `img/` download cache
|
|
- `print_image()` reconnects and retries once on failure and returns the (possibly new) printer handle — callers must rebind `p`
|
|
- Commands that don't need the printer (`list`, `clean`) or handle their own connection (`status`) are dispatched in `main()` before connecting
|
|
|
|
## Checks
|
|
|
|
```bash
|
|
pytest # required
|
|
ruff check . # lint (config in pyproject.toml)
|
|
```
|
|
|
|
Actual printing can only be verified with the physical printer attached.
|