dct 0.0.7
dotnet tool install --global dct --version 0.0.7
dotnet new tool-manifest
dotnet tool install --local dct --version 0.0.7
#tool dotnet:?package=dct&version=0.0.7
nuke :add-package dct --version 0.0.7
dct (Dotnet CLI Tool)
A .NET global CLI tool to rapidly generate CQRS and Clean Architecture components such as commands, queries, handlers, classes, and interfaces. Streamline your development workflow and enforce best practices with customizable templates and configuration.
Features
- Generate CQRS artifacts: commands, queries, handlers
- Create classes and interfaces with a single command
- Initialize default config and templates
- Fully customizable via templates and configuration
- Fast, scriptable, and easy to use
Installation
After publishing to NuGet, install globally with:
dotnet tool install -g dct
Getting Started
Before using dct, you must initialize and configure it in your project:
dct init
This command creates a .dct folder in your project root, containing all templates and a .dct-config file. All code generation is based on these templates and your configuration. You can customize the templates and .dct/.dct-config to fit your project's needs. With proper configuration, dct can generate any artifact or file structure you require.
Usage
Show version
dct --version
Initialize configuration and templates (required before first use)
dct init
Generate an artifact (command, query, handler, class, interface, or any custom template)
dct create <artifact> <path>
<artifact>: Type of artifact to generate (e.g.,command,query,handler,class,interface, or any custom template name)<path>: Target path or name for the generated file(s)
Examples
| Command | Description |
|---|---|
dct --version |
Show the installed dct version |
dct init |
Initialize config and templates (must be run first) |
dct create command User/CreateUser |
Generate a command in User/CreateUser |
dct create handler User/CreateUserHandler |
Generate a handler |
dct create query User/GetUser |
Generate a query |
dct create class Models/User |
Generate a class |
dct create interface Services/IUserService |
Generate an interface |
Customization
Configuration
Customize generation by editing the .dct/.dct-config file in your project root. Example:
{
"templatePaths": {
"command": "./dct-templates/command.scriban",
"query": "./dct-templates/query.scriban",
"handler": "./dct-templates/handler.scriban"
}
}
Templates
You can override default templates or add your own by placing them in the .dct/Templates/ directory. Supported templates include:
command.scribanhandler.scribanquery.scriban- Any custom template you define
Edit these files to match your coding standards and patterns. The tool will use your configuration and templates to generate code exactly as you need.
Development
Dependencies
License
MIT License
© 2024 Mikheil Berishvili. See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.