CLI
CLI Commands
All toni-cli commands — new project creation and code generation.
toni new
Create a new Toni project from a starter template.
toni new <project-name>Example:
toni new my_api
cd my_api
cargo runThe generated project includes:
Cargo.tomlwithtoniandtoni-axumdependenciessrc/main.rswithToniFactory::createsetupsrc/app_module.rs— root modulesrc/app_controller.rs— example controller with aGET /routesrc/app_service.rs— example service
toni generate
Generate boilerplate for common Toni components.
toni generate <type> <name>Subcommands
toni generate module UserModule
# Creates: src/users/users_module.rs
toni generate controller UserController
# Creates: src/users/users_controller.rs
toni generate service UserService
# Creates: src/users/users_service.rsThe generated files include the appropriate #[module], #[controller], or #[injectable] attributes with placeholder implementations.
Example — generated service
toni generate service AuthServiceGenerates src/auth/auth_service.rs:
use toni::injectable;
#[injectable(pub struct AuthService {})]
impl AuthService {
pub fn new() -> Self {
Self {}
}
}Example — generated controller
toni generate controller AuthControllerGenerates src/auth/auth_controller.rs:
use toni::{controller, HttpResponse};
#[controller("/auth", pub struct AuthController {})]
impl AuthController {
pub fn new() -> Self {
Self {}
}
#[get("")]
fn index(&self) -> HttpResponse {
HttpResponse::ok().build()
}
}Planned commands
The following commands are planned for future releases:
| Command | Description |
|---|---|
toni generate guard <name> | Generate a Guard implementation |
toni generate interceptor <name> | Generate an Interceptor |
toni generate middleware <name> | Generate Middleware |
toni generate pipe <name> | Generate a Pipe |
Track progress on the GitHub repository.