# Snap Pea
The [P](https://github.com/p-org/P) modeling language in Rust: a parser, type checker
and model checker with no .NET, Java or code generation, plus helpers to check the
events your application emits against P specs.
## The `snappea` tool
```sh
cargo install snappea # installs snappea and snappea-compat
snappea check # check every test case of the .pproj in this folder
snappea observe --spec BankBalanceCorrect logs/ # check production logs
```
`snappea-compat` is a drop-in replacement for upstream's `p` command.
## Library
`cargo add --dev snappea` for tests. Production code needs only the emitter:
```toml
[dependencies]
snappea = { version = "0.1", default-features = false, features = ["emit"] }
[dev-dependencies]
snappea = "0.1"
```
```rust,ignore
// Application code. With only the `emit` feature, no checker is compiled in.
snappea::emit::emit("eReserved", "coffee", snappea::emit::json!({"order": "o1", "units": 2}));
// A test: everything emitted while the closure runs is checked against the P specs
// configured in [package.metadata.snappea] of Cargo.toml.
let model = snappea::test::Model::load()?;