|
| 1 | +# Getting Started |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +Install the Rust toolchain and `cargo-generate`: |
| 6 | + |
| 7 | +```bash |
| 8 | +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 9 | +cargo install cargo-generate |
| 10 | +``` |
| 11 | + |
| 12 | +## Create a Project |
| 13 | + |
| 14 | +```bash |
| 15 | +cargo generate rararulab/cli-template |
| 16 | +``` |
| 17 | + |
| 18 | +You'll be prompted for three values: |
| 19 | + |
| 20 | +| Placeholder | Format | Example | Used For | |
| 21 | +|------------------|------------|------------------|-----------------------------------| |
| 22 | +| `project-name` | kebab-case | `my-awesome-cli` | Binary name, directory, npm pkg | |
| 23 | +| `crate_name` | snake_case | *(auto-derived)* | Rust module name | |
| 24 | +| `github-org` | — | `myorg` | Repo URLs, CI badges | |
| 25 | + |
| 26 | +> `crate_name` is derived automatically from `project-name` — you rarely need to change it. |
| 27 | +
|
| 28 | +## First Run |
| 29 | + |
| 30 | +```bash |
| 31 | +cd my-awesome-cli |
| 32 | +cargo check |
| 33 | +cargo test |
| 34 | +cargo run -- --help |
| 35 | +cargo run -- hello world |
| 36 | +``` |
| 37 | + |
| 38 | +The `hello` command is a working example wired end-to-end. Use it as a reference when adding your own commands. |
| 39 | + |
| 40 | +## What to Customize |
| 41 | + |
| 42 | +Once you've verified the template builds, update these files: |
| 43 | + |
| 44 | +- **`CLAUDE.md`** — add a description of your project for AI-assisted development |
| 45 | +- **`Cargo.toml`** — set `description`, `repository`, and `homepage` |
| 46 | +- **`src/cli/mod.rs`** — replace the example `Hello` command with your own |
| 47 | +- **`src/app_config.rs`** — replace `ExampleConfig` with your app's config fields |
| 48 | +- **`README.md`** — rewrite for your project |
| 49 | + |
| 50 | +## Clean Up Example Code |
| 51 | + |
| 52 | +Once your first real command is in place, remove the scaffolding: |
| 53 | + |
| 54 | +1. Delete the `Hello` variant from the `Command` enum in `src/cli/mod.rs` |
| 55 | +2. Delete its match arm in `main.rs` |
| 56 | +3. Replace `ExampleConfig` in `src/app_config.rs` with your own config struct |
| 57 | + |
| 58 | +> Don't delete the example code until you have a real command working. It serves as a reference for the patterns used throughout the template. |
| 59 | +
|
| 60 | +## Verify |
| 61 | + |
| 62 | +```bash |
| 63 | +cargo check && cargo test && cargo clippy |
| 64 | +``` |
| 65 | + |
| 66 | +All three should pass cleanly before your first commit. |
| 67 | + |
| 68 | +## Next Steps |
| 69 | + |
| 70 | +- [Project Structure](guide/project-structure.md) — understand the module layout and conventions |
0 commit comments