|
1 | 1 | # cargo-rustapi |
2 | 2 |
|
3 | | -The official CLI tool for the RustAPI framework. Scaffold new projects, run development servers, and manage database migrations. |
| 3 | +**The official CLI tool for the RustAPI framework.** |
4 | 4 |
|
5 | | -## Installation |
| 5 | +Use this tool to scaffold new projects, generate code, and fast-track your development workflow. |
6 | 6 |
|
7 | | -`ash |
| 7 | +## 📦 Installation |
| 8 | + |
| 9 | +```bash |
8 | 10 | cargo install cargo-rustapi |
9 | | -` |
| 11 | +``` |
10 | 12 |
|
11 | | -## Features |
| 13 | +## 🛠️ Usage |
12 | 14 |
|
13 | | -- **Project Scaffolding**: Create new projects with |
14 | | -ew command, choosing from templates like pi, web, or ull. |
15 | | -- **Development Server**: Run your project with un command, supporting hot-reloading (via cargo-watch integration if available). |
16 | | -- **Code Generation**: Generate handlers, models, and CRUD operations with generate. |
17 | | -- **Database Management**: (Planned) Simple wrappers around migration tools. |
| 15 | +### Creating a New Project |
18 | 16 |
|
19 | | -## Usage |
| 17 | +Use the `new` command to generate a project structure. |
20 | 18 |
|
21 | | -### Create a New Project |
| 19 | +```bash |
| 20 | +# Interactive mode (Recommended) |
| 21 | +cargo rustapi new my-app |
22 | 22 |
|
23 | | -`ash |
24 | | -# Interactive mode |
25 | | -cargo rustapi new my-project |
| 23 | +# Quick start with specific template |
| 24 | +cargo rustapi new my-app --template api |
| 25 | +``` |
26 | 26 |
|
27 | | -# With template |
28 | | -cargo rustapi new my-project --template api |
| 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. |
29 | 32 |
|
30 | | -# With features |
31 | | -cargo rustapi new my-project --features jwt,cors |
32 | | -` |
| 33 | +### Running Development Server |
33 | 34 |
|
34 | | -### Run Development Server |
| 35 | +Run your application with hot-reloading (requires `cargo-watch`). |
35 | 36 |
|
36 | | -`ash |
37 | | -# Run with auto-reload |
| 37 | +```bash |
38 | 38 | cargo rustapi run |
| 39 | +``` |
39 | 40 |
|
40 | | -# Run on specific port |
41 | | -cargo rustapi run --port 8080 |
42 | | -` |
| 41 | +### Code Generation |
43 | 42 |
|
44 | | -### Generate Code |
| 43 | +Save time by generating boilerplate. |
45 | 44 |
|
46 | | -`ash |
47 | | -# Generate a new handler |
| 45 | +```bash |
| 46 | +# Generate a handler function and register it |
48 | 47 | cargo rustapi generate handler users |
49 | 48 |
|
50 | | -# Generate a model |
| 49 | +# Generate a database model |
51 | 50 | cargo rustapi generate model User |
52 | 51 |
|
53 | | -# Generate CRUD endpoints (Handlers + Models + Tests) |
54 | | -cargo rustapi generate crud users |
55 | | -` |
56 | | - |
57 | | -## Templates |
58 | | - |
59 | | -- minimal: Bare bones setup. |
60 | | -- pi: REST API structure with handlers and models. |
61 | | -- web: Includes ustapi-view and emplates folder. |
62 | | -- ull: Complete setup with Auth, DB (SQLx), and more. |
| 52 | +# Generate a full CRUD resource (Model + Handlers + Tests) |
| 53 | +cargo rustapi generate crud product |
| 54 | +``` |
63 | 55 |
|
64 | | -## License |
| 56 | +### Managing Migrations (Planned) |
65 | 57 |
|
66 | | -MIT OR Apache-2.0 |
| 58 | +```bash |
| 59 | +cargo rustapi migrate run |
| 60 | +cargo rustapi migrate revert |
| 61 | +``` |
0 commit comments