1# Chapter 21: cargo-gen/src, two verbs 2 3One file with two verbs: 4 5```text 6cargo-gen generate <out-dir> <version> <edition> <majors> <third-party/Cargo.toml> <meta.json>... 7cargo-gen write <generated-dir> 8``` 9 10`generate` runs inside the buck build (`:manifests`). It reads every 11target's JSON, groups targets into packages, and writes the tree of 12manifests the BUCK files imply: the root workspace with its members and 13`[workspace.dependencies]` (crates.io versions from `third-party/Cargo.toml`, 14pgrx at `=0.19.2` with its major feature stripped, so the per-crate `pgNN` 15features choose it), and one `Cargo.toml` per package, a package's unit-test 16target adding its dev-dependencies. `write` runs outside it (`:update`) and 17copies that tree into the checkout that holds the current directory. 18 19> **Try it.** Read the header of [main.rs](main.rs), then compare the root 20> [Cargo.toml](../../../Cargo.toml): its first four lines are the warning the 21> tool writes at the top of every file it owns. 22 23## For the people who maintain it 24 25| File | What | 26| --- | --- | 27| [main.rs](main.rs) | `generate` and `write`. Errors go to stderr as `cargo-gen: …` with exit code 1. | 28 29← Previous: [Chapter 20, cargo-gen/](../) · Up: [cargo-gen](../) · Next: [Chapter 22, third-party-notices/](../../third-party-notices/) →