Usage
Reference for the corvis commands. Options start with -- and can go in any position after the command.
corvis new
corvis new <name> [--corvis-path <path>] [--corvis-version <requirement>] [--skip-git]Creates the project folder (the name in kebab-case) with Cargo.toml, .env, .gitignore and src/ with main.rs, app_module.rs, app_controller.rs and app_service.rs. It fails if the folder already exists.
| Option | Effect |
|---|---|
--corvis-path <path> | Dependency corvis = { path = "<path>" }. Without it, CORVIS_PATH or the copy the CLI was built from is used |
--corvis-version <requirement> | Dependency corvis = { version = "<requirement>" } (a Cargo version requirement) |
--skip-git | Does not run git init |
The name must start with a letter and contain only letters, digits, - and _.
corvis generate
corvis generate <schematic> <name> [--flat] [--path <module>] [--no-spec]
corvis g <schematic> <name> ...It runs inside a project: it searches upward for the first folder with Cargo.toml and src/.
Schematics
| Schematic | Alias | Generates | Registers it in |
|---|---|---|---|
module | mo | XModule | imports of AppModule |
controller | co | XController with a GET and a test | controllers of the folder's module, or of AppModule |
service | s | XService (#[injectable]) with a test | providers of the folder's module, or of AppModule |
resource | res | Module, CRUD controller, service, DTOs, entity and test | imports of AppModule |
guard | gu | XGuard (CanActivate) | Not registered |
interceptor | itc, in | XInterceptor (CorvisInterceptor) | Not registered |
pipe | pi | XPipe (PipeTransform) | Not registered |
filter | f | XFilter (ExceptionFilter) | Not registered |
middleware | mi | XMiddleware (CorvisMiddleware) | Not registered |
gateway | ga | XGateway (#[websocket_gateway]) | providers of the folder's module, or of AppModule |
Guards, interceptors, pipes, filters and middleware are not registered because they are used with #[use_guards(...)], #[use_interceptors(...)], consumer.apply::<...>() or the use_global_* methods, depending on the case.
Where the files are written
With corvis g service users:
src/
├── main.rs # + mod users;
├── app_module.rs # + providers = [UsersService] (if src/users/users_module.rs does not exist)
└── users/
├── mod.rs # + pub mod users_service; pub use users_service::UsersService;
└── users_service.rsIf src/users/users_module.rs exists (for example, because you ran corvis g module users earlier), the service is registered in UsersModule instead of AppModule. The CLI also adds the necessary use lines.
The exact rule is: it looks for src/<folder>/<name>_module.rs and, if it does not exist, uses src/app_module.rs. That is why corvis g controller profile --path users looks for src/users/profile_module.rs and, not finding it, registers the controller in AppModule even if users_module.rs exists; in that case, move it by hand to the right module.
| Option | Effect |
|---|---|
--flat | Writes the file in src/ (src/users_service.rs) instead of a folder |
--path <module> | Uses another folder: corvis g controller profile --path users writes to src/users/. It must be a valid Rust module name |
--no-spec | Omits the #[cfg(test)] module from the generated file |
If a file already exists, the command fails without overwriting it. When the CLI does not recognize the shape of a file it has to modify, it reports SKIP and you have to do the registration by hand.
Type names are derived from the argument: user-profile, user_profile and UserProfile produce UserProfileService in user_profile_service.rs, with the route user-profile in controllers.
corvis start
corvis start [--watch] [--release] [-- <program arguments>]| Form | Runs |
|---|---|
corvis start | cargo run |
corvis start --release (or --prod) | cargo run --release |
corvis start -- --my-flag | cargo run -- --my-flag |
corvis start --watch | cargo watch -x run |
--watch needs cargo-watch (cargo install cargo-watch). In that mode, --release and the arguments after -- are ignored.
corvis build
corvis build [--release]Runs cargo build, or cargo build --release with --release (or --prod).
corvis info
Shows the operating system and architecture, rustc --version, cargo --version and the CLI version. Useful to attach to a bug report.