--- description: posprint development conventions globs: **/* alwaysApply: true --- # posprint development rules ## Language and dependencies - Single language: **Rust** with **egui** (eframe) for the UI. - Prefer std library and in-house code. Add a crate only when reimplementing would be unreasonable (e.g. `serialport`, `serde`, `image`, UI framework). - ESC/POS encoding lives in `src/escpos.rs` — do not add the `escpos` crates.io package. - Printing: USB printer-class (`rusb`), Windows spooler, USB-serial, and OS-paired Classic Bluetooth SPP (`serialport`). Do not add BLE or network printing until explicitly requested. ## Testing - **Every module must have unit tests** in `#[cfg(test)] mod tests` (or `tests/` for integration). - New behaviour requires new tests in the same commit. - Run `cargo test` before merging; all tests must pass. - Use `MockTransport` for printer I/O in tests; never require hardware in CI. ## Branches and commits - Default branch: `master`. - Use `feature/` or `fix/` branches for changes. - **Always commit without waiting for the user to ask.** There is no reason to leave work uncommitted; frequent, focused commits are required so changes can be reverted if something goes wrong. - Commit after every logical unit of work (e.g. a bug fix, a new feature slice, tests for that slice, or a doc sync tied to the same change). Do not batch an entire session into one commit at the end. - **Never end a task with uncommitted changes** in the working tree. If you edited files, commit them before finishing. - Commit messages: short imperative summary of *why* (one line is fine); body optional for non-obvious context. - Merge to `master` only after `cargo test` is green. ## Git merges - **Never fast-forward.** Always create a merge commit: ```bash git checkout master git merge --no-ff feature/your-branch ``` - Do not use `git pull --ff-only` when integrating a merged feature branch into `master`. ## Branch cleanup - After a successful merge to `master`, delete the local branch: ```bash git branch -d feature/your-branch ``` - If a feature branch was pushed to the remote, delete it there too once merged: ```bash git push origin --delete feature/your-branch ``` - Periodically prune stale remote-tracking refs: `git fetch --prune` ## Documentation - See `.cursor/rules/documentation.mdc` for full doc-sync rules. - Keep `docs/HELP.md` in sync with supported DSL and UI features. - The in-app Help tab must mirror `docs/HELP.md` (via `include_str!` in `src/lib.rs`). - Update `docs/ARCHITECTURE.md`, `docs/PRINTING.md`, etc. when implementation diverges from design. ## Releases - GitLab CI (`.gitlab-ci.yml`) runs tests on **merge requests**; tagged releases build artifacts. - Tagged releases produce Windows `.exe`, Debian `.deb` (apt), and Arch `.pkg.tar.zst` (pacman). - Debian packages use `cargo-deb` and `[package.metadata.deb]` in `Cargo.toml`. - Arch packages use `packaging/arch/PKGBUILD` and `makepkg`.