|
1 | 1 | # cargo-rustapi |
2 | 2 |
|
3 | | -**The official CLI tool for the RustAPI framework.** |
| 3 | +**Lens**: "The Architect" |
| 4 | +**Philosophy**: "Scaffolding best practices from day one." |
4 | 5 |
|
5 | | -Use this tool to scaffold new projects, generate code, and fast-track your development workflow. |
| 6 | +The RustAPI CLI isn't just a project generator; it's a productivity multiplier. |
6 | 7 |
|
7 | 8 | ## 📦 Installation |
8 | 9 |
|
9 | 10 | ```bash |
10 | 11 | cargo install cargo-rustapi |
11 | 12 | ``` |
12 | 13 |
|
13 | | -## 🛠️ Usage |
| 14 | +## 🛠️ Commands |
14 | 15 |
|
15 | | -### Creating a New Project |
| 16 | +| Command | Description | |
| 17 | +|---------|-------------| |
| 18 | +| `cargo rustapi new <name>` | Create a new project with the perfect directory structure | |
| 19 | +| `cargo rustapi run` | Run the development server | |
| 20 | +| `cargo rustapi run --reload` | Run with hot-reload (auto-rebuild on file changes) | |
| 21 | +| `cargo rustapi generate resource <name>` | Scaffold a new API resource (Model + Handlers + Tests) | |
| 22 | +| `cargo rustapi client --spec <path> --language <lang>` | Generate a client library (Rust, TS, Python) from OpenAPI spec | |
| 23 | +| `cargo rustapi deploy <platform>` | Generate deployment configs for Docker, Fly.io, Railway, or Shuttle | |
| 24 | +| `cargo rustapi migrate <action>` | Database migration commands (create, run, revert, status, reset) | |
16 | 25 |
|
17 | | -Use the `new` command to generate a project structure. |
| 26 | +## 🚀 Quick Start |
18 | 27 |
|
19 | 28 | ```bash |
20 | | -# Interactive mode (Recommended) |
21 | | -cargo rustapi new my-app |
22 | | - |
23 | | -# Quick start with specific template |
| 29 | +# Create a new project |
24 | 30 | cargo rustapi new my-app --template api |
25 | | -``` |
26 | | - |
27 | | -**Available Templates:** |
28 | | -- `minimal`: Basic `main.rs` and `Cargo.toml`. |
29 | | -- `api`: REST API structure with separated `handlers` and `models`. |
30 | | -- `web`: Web application with HTML templates (`rustapi-view`). |
31 | | -- `full`: Complete example with Database, Auth, and Docker support. |
32 | 31 |
|
33 | | -### Running Development Server |
34 | | - |
35 | | -Run your application with hot-reloading (requires `cargo-watch`). |
36 | | - |
37 | | -```bash |
38 | | -cargo rustapi run |
| 32 | +# Run with auto-reload |
| 33 | +cd my-app |
| 34 | +cargo rustapi run --reload |
39 | 35 | ``` |
40 | 36 |
|
41 | | -### Code Generation |
42 | | - |
43 | | -Save time by generating boilerplate. |
| 37 | +## 📁 Templates |
44 | 38 |
|
45 | | -```bash |
46 | | -# Generate a handler function and register it |
47 | | -cargo rustapi generate handler users |
48 | | - |
49 | | -# Generate a database model |
50 | | -cargo rustapi generate model User |
51 | | - |
52 | | -# Generate a full CRUD resource (Model + Handlers + Tests) |
53 | | -cargo rustapi generate crud product |
54 | | -``` |
| 39 | +The templates used by the CLI are opinionated but flexible. They enforce: |
| 40 | +- Modular folder structure |
| 41 | +- Implementation of `State` pattern |
| 42 | +- Separation of `Error` types |
55 | 43 |
|
56 | | -### Managing Migrations (Planned) |
57 | | - |
58 | | -```bash |
59 | | -cargo rustapi migrate run |
60 | | -cargo rustapi migrate revert |
61 | | -``` |
| 44 | +**Available Templates:** |
| 45 | +- `minimal`: Basic `main.rs` and `Cargo.toml` |
| 46 | +- `api`: REST API structure with separated `handlers` and `models` |
| 47 | +- `web`: Web application with HTML templates (`rustapi-view`) |
| 48 | +- `full`: Complete example with Database, Auth, and Docker support |
0 commit comments